// No soup for you. header('Location: ' . redirect()); exit; } $mfg = new Manufacturer(); // AJAX Start if (isset($_GET['getManufacturers'])) { header('Content-Type: application/json'); echo json_encode($mfg->GetManufacturerList()); exit; } if (isset($_GET['getTemplateCount']) && isset($_GET['ManufacturerID'])) { $temp = new DeviceTemplate(); $temp->ManufacturerID = $_GET['ManufacturerID']; header('Content-Type: application/json'); echo json_encode($temp->GetTemplateListByManufacturer()); exit; } if (isset($_POST['setManufacturer'])) { $mfg->ManufacturerID = $_POST['ManufacturerID']; $mfg->GetManufacturerByID(); $mfg->GlobalID = $_POST['GlobalID']; $mfg->Name = $_POST['Name']; $mfg->SubscribeToUpdates = isset($_POST['SubscribeToUpdates']) ? 1 : 0; if ($mfg->ManufacturerID == "") { $mfg->CreateManufacturer(); } else { $mfg->UpdateManufacturer(); } header('Content-Type: application/json'); echo json_encode($mfg);
function DeleteManufacturer($TransferTo = null) { $this->MakeSafe(); $tmpl = new DeviceTemplate(); $tmpl->ManufacturerID = $this->ManufacturerID; $templates = $tmpl->GetTemplateListByManufacturer(); // If a TransferTo isn't supplied then just delete the templates that depend on this key foreach ($templates as $DeviceTemplate) { // A manufacturerid of 0 is impossible so if we get that via something f**k 'em delete if (!is_null($TransferTo) && intval($TransferTo) > 0) { $DeviceTemplate->ManufacturerID = $TransferTo; $DeviceTemplate->UpdateTemplate(); } else { // This option is not being provided but us at this time, maybe through the API $DeviceTemplate->DeleteTemplate(); } } $sql = "DELETE FROM fac_Manufacturer WHERE ManufacturerID={$this->ManufacturerID};"; class_exists('LogActions') ? LogActions::LogThis($this) : ''; return $this->query($sql); }