Example #1
0
    /**
     * Load all available materials.
     *
     * @return \self
     */
    public static function loadList()
    {
        $sql = '
			SELECT `materialId`
			FROM materials
			WHERE !deleted
			ORDER BY `name`
		';
        $materialIds = query($sql, true);
        $obj = new self();
        if (empty($materialIds)) {
            return $obj;
        }
        $list = array();
        foreach ($materialIds as $material) {
            $list[$material['materialId']] = \Model\Material::loadById($material['materialId']);
        }
        $obj->setList($list);
        return $obj;
    }
Example #2
0
 /**
  * Remove a material.
  *
  * @param \Model\Material $material
  *
  * @return void
  */
 protected function removeMaterial($material)
 {
     $material->remove();
     $this->doRender = false;
     $this->echoAjaxResponse(array('ok' => true));
 }
Example #3
0
<?php

/**
 * Add a new material.
 *
 * @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\Material::create($_POST['data']);
echo json_encode(array('ok' => $response));
Example #4
0
    /**
     * Load the materials for the blueprint.
     *
     * @return void
     */
    public function loadMaterials()
    {
        $sql = '
			SELECT
				`materialId`,
				`materialAssetId`,
				percentage,
				talent
			FROM materialsToBlueprints
			WHERE `blueprintId` = ' . \sqlval($this->blueprintId) . '
				AND !deleted
		';
        $materialIds = query($sql, true);
        $list = array();
        foreach ($materialIds as $material) {
            $list[$material['materialId']] = array('material' => \Model\Material::loadById($material['materialId']), 'materialAsset' => \Model\MaterialAsset::loadById($material['materialAssetId']), 'percentage' => intval($material['percentage']), 'talent' => $material['talent']);
        }
        $this->materialList = $list;
    }