public function getDescription($db) { if (count($this->services) != 0) { foreach ($this->services as $serviceId) { $serviceItem = new ChiconService($db, $serviceId); $jsonArray[] = $serviceItem->getServiceDescription(); unset($serviceItem); } $returnArray = array("cart" => $jsonArray); return $returnArray; } return $returnArray = array("cart" => null); }
$hdwSerial = $_GET['hdwSerial']; $myHdw = ChiconHardware::toAssign($db, $hdwSerial); if ($myHdw->delFromUser($user->getUserId())) { $result = array("result" => array("code" => 200, "data" => "Hardware deleted")); } else { $result = array("result" => array("code" => 400, "data" => "Hardware deletion error")); } } else { $result = array("result" => array("code" => 400, "data" => array("error" => "Bad command"))); } echo json_encode($result); break; case "ledSelected": if (isset($_GET['hdwSerial']) and isset($_GET['led']) and $user->isUserHardware($_GET['hdwSerial'])) { require '../class/ChiconService.class.php'; $mySrv = ChiconService::withHdwLedId($db, $_GET['led'], $_GET['hdwSerial']); if ($mySrv != null) { $mySrv->runSelectedLed(); $result = array("result" => array("code" => 200, "data" => "Led selection success")); } else { $result = array("result" => array("code" => 400, "data" => "unknown service")); } } else { $result = array("result" => array("code" => 400, "data" => array("error" => "Bad command"))); } echo json_encode($result); break; case "getCartItemsCount": require '../class/ChiconCart.class.php'; $myCart = ChiconCart::restoreFromSession(); $result = array("result" => array("code" => 200, "data" => array("cart" => $myCart->countItems())));
switch ($cmd) { case "getLedDescription": if (isset($_GET['srvId'])) { require '../class/ChiconService.class.php'; $srvId = $_GET['srvId']; $service = new ChiconService($db, $srvId); $result = array("result" => array("code" => 200, "data" => $service->getLedDescription())); } else { $result = array("result" => array("code" => 400, "data" => array("error" => "Bad command"))); } echo json_encode($result); break; case "getAllServices": require '../class/ChiconServiceFabric.class.php'; $serviceFabric = new ChiconServiceFabric($db); $result = array("result" => array("code" => 200, "data" => $serviceFabric->getAllServices())); echo json_encode($result); break; case "getServiceDescription": if (isset($_GET['srvId'])) { require '../class/ChiconService.class.php'; $srvId = $_GET['srvId']; $service = new ChiconService($db, $srvId); $result = array("result" => array("code" => 200, "data" => $service->getServiceDescription())); } else { $result = array("result" => array("code" => 400, "data" => array("error" => "Bad command"))); } echo json_encode($result); break; } }
if (isset($_GET['mn'])) { $mn = $_GET['mn']; $myHdw = new ChiconHardware($db, $mn); if ($myHdw->isRegistered()) { $myHdw->getSerialNumber(); if (isset($_GET['srv'])) { if ($myHdw->isServiceRegistered($_GET['srv'])) { $mySrv = ChiconService::withHardware($db, $_GET['srv'], $myHdw->getSerialNumber()); $mySrv->run(); } else { echo "{error:'Unknown service'}"; } } elseif (isset($_GET['cfg'])) { $myHdw->getJsonConfig(); } elseif (isset($_GET['led'])) { $mySrv = ChiconService::withHdwLedId($db, $_GET['led'], $myHdw->getSerialNumber()); if ($mySrv != null) { $mySrv->runSelectedLed(); $mySrv->run(); } else { echo "{error:'Unknown service'}"; } } } else { //TODO check if force registered is set, if yes force registered else send error echo "{error:'Unknown hdw'}"; } } else { if (isset($_GET['sHdw']) and isset($_GET['rgt'])) { $myHdw = ChiconHardware::withSerial($db, $_GET['sHdw']); if (!$myHdw->isEnrolled()) {