/** * Load all available material types. * * @return \self */ public static function loadList() { $sql = ' SELECT `materialTypeId` FROM materialTypes WHERE !deleted ORDER BY `name` '; $materialTypeIds = query($sql, true); $obj = new self(); if (empty($materialTypeIds)) { return $obj; } $list = array(); foreach ($materialTypeIds as $materialType) { $list[$materialType['materialTypeId']] = \Model\MaterialType::loadById($materialType['materialTypeId']); } $obj->setList($list); return $obj; }
/** * Get the material type. * * @return string */ public function getMaterialType() { return $this->materialType->getName(); }
<?php /** * Add a new material type. * * @package ajax * @author friend8 <*****@*****.**> * @license https://www.gnu.org/licenses/lgpl.html LGPLv3 */ require_once __DIR__ . '/../lib/system/config.default.php'; require_once __DIR__ . '/../lib/system/util/mysql.php'; $response = \Model\MaterialType::create(array('name' => $_POST['name'])); if ($response) { $response['ok'] = true; echo json_encode($response); die; } echo json_encode(array('ok' => false));