/** * Get the time already used for producing this item. * * @param boolean $format * * @return string|integer */ public function getCurrentProductionTime($format = true) { $time = $this->doneProofs * ($this->blueprint->getTimeUnits() * $this->timeUnitSeconds); if ($format) { return $this->formatProductionTime($time); } return $time; }
/** * Load all available blueprints for the logged in user. * * @return \self */ public static function loadList($orderBy = 'name') { $sql = ' SELECT `blueprintId` FROM blueprints WHERE userid = ' . \sqlval($_SESSION['userId']) . ' AND !deleted ORDER BY ' . sqlval($orderBy, false) . ' '; $blueprintIds = query($sql, true); $obj = new self(); if (empty($blueprintIds)) { return $obj; } $list = array(); foreach ($blueprintIds as $blueprint) { $list[$blueprint['blueprintId']] = \Model\Blueprint::loadById($blueprint['blueprintId']); } $obj->setList($list); return $obj; }
<?php /** * Show the stats for a blueprint of an item. * * @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'; $blueprint = \Model\Blueprint::loadById($_POST['id']); echo json_encode($blueprint->getResultingStats());
/** * Remove a blueprint. * * @param \Model\Blueprint $blueprint * * @return void */ protected function removeBlueprint($blueprint) { $blueprint->remove(); redirect('index.php?page=Blueprints'); }
<?php /** * Add a new blueprint into the database. * * @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'; session_start(); $response = \Model\Blueprint::create(array_merge(array('userId' => $_SESSION['userId']), $_POST['data'])); echo json_encode(array('ok' => $response));