/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Type::got_property($id) == false) {
         $this->type->find($id)->delete();
     }
     return Redirect::route('admin.types.index');
 }
 public function searchAction()
 {
     $numberPage = 1;
     if ($this->request->isPost()) {
         $query = Criteria::fromInput($this->di, "ProductTypes", $_POST);
         $this->persistent->searchParams = $query->getParams();
     } else {
         $numberPage = $this->request->getQuery("page", "int");
         if ($numberPage <= 0) {
             $numberPage = 1;
         }
     }
     $parameters = array();
     if ($this->persistent->searchParams) {
         $parameters = $this->persistent->searchParams;
     }
     $productTypes = Type::find($parameters);
     if (count($productTypes) == 0) {
         $this->flash->notice("没有找到对应类型");
         return $this->forward("producttypes/index");
     }
     $paginator = new Phalcon\Paginator\Adapter\Model(array("data" => $productTypes, "limit" => 10, "page" => $numberPage));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
     $this->view->setVar("productTypes", $productTypes);
 }
Esempio n. 3
0
 public function getDelete($id)
 {
     $Type = Type::find($id);
     $Type->delete();
     Session::flash('message', 'The records are deleted successfully');
     return Redirect::to('type');
 }
Esempio n. 4
0
 function beforeDelete($cascade)
 {
     // Remove the extended data to be tidy.
     // First get the type id
     App::Import('Model', 'Type');
     $Type = new Type();
     $Type->recursive = -1;
     $type_record = Set::extract('/Type/id', $Type->find('first', array('fields' => array('Type.id'), 'conditions' => array('Type.alias' => $this->model->data['Node']['type']))));
     $type_id = $type_record[0];
     // Cool, now find all node schemas
     App::Import('Model', 'NodeSchema.NodeSchema');
     $NodeSchema = new NodeSchema();
     $NodeSchema->actsAs = array('Containable');
     $schemas = $NodeSchema->find('all', array('fields' => array('NodeSchema.table_name'), 'contains' => array('Type' => array('conditions' => array('Type.id' => $type_id)))));
     // Now loop through and check for records on those tables to remove
     if (is_array($schemas) && count($schemas) > 0) {
         foreach ($schemas as $schema) {
             $table_name = $schema['NodeSchema']['table_name'];
             $model = new Model(false, $table_name);
             $model->primaryKey = 'node_id';
             // set the primary key to the node_id
             if ($model->delete($this->model->data['Node']['id'], false)) {
                 return true;
             } else {
                 // return false; // There was some sort of error deleting the associated data. Do we even need this? It doesn't redirect, it stops. Have to handle the error.
             }
         }
     }
     return true;
 }
Esempio n. 5
0
 public function specific_type($id)
 {
     $type = Type::find($id);
     $medicines = $type->medicine;
     $name = $type->type;
     //$pets = Pet::where("type_id", "Compact Living")->get();
     return View::make('medicines.index', compact('medicines', 'name', 'type'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function edit($id)
 {
     $school = School::find($id);
     if (is_null($school)) {
         return Redirect::route('admin.schools.index')->withErrors(array('mainError' => 'Училището не е намерено.'));
     } else {
         $school_name = Type::find($school->type_id)->name . ' "' . $school->name . '"';
         $comments = VisitorComments::where("school_id", "=", $id)->get();
         return View::make('admin.school.comments')->with('school_name', $school_name)->with('comments', $comments);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $type = Type::find($id);
     if (!is_null($type)) {
         if ($type->delete()) {
             return Redirect::route('admin.types.index')->withErrors(array('mainSuccess' => 'Видът на учебното заведение е успешно изтрит.'));
         } else {
             return Redirect::route('admin.types.index')->withErrors(array('mainError' => 'Грешка с базата данни.'));
         }
     } else {
         return Redirect::route('admin.types.index')->withErrors(array('mainError' => 'Вид на училище не е намерен.'));
     }
 }
Esempio n. 8
0
 public function type()
 {
     if (!isset($_GET['url'])) {
         exit;
     }
     # TODO
     $type = new Type(array("url" => $_GET['url']));
     if ($type->no_results) {
         exit;
     }
     # TODO
     $can_create = Visitor::current()->group()->can("add_extension");
     $this->display("extend/type", array("type" => $type, "users" => $can_create ? User::find() : array(), "types" => $can_create ? Type::find() : array()), $type->name);
 }
 public function editAction($id)
 {
     $request = $this->request;
     if (!$request->isPost()) {
         $id = $this->filter->sanitize($id, array("int"));
         $Finance = Finance::findFirst('id="' . $id . '"');
         if (!$Finance) {
             $this->flash->error("这条记录没有找到!");
             return $this->forward("products/list");
         }
         $departments = Department::find();
         $this->view->setVar("departments", $departments);
         Tag::displayTo("company", $Finance->did);
         $typeArr;
         $type = Type::find();
         foreach ($type as $k => $v) {
             $types = Types::find("fid = '" . $v->id . "'");
             $typeArr[$v->name] = $types->toArray();
         }
         $this->view->setVar("typeArr", $typeArr);
         $this->view->setVar("id", $Finance->id);
         $datas = json_decode($Finance->data, true);
         foreach ($typeArr as $key => $val) {
             foreach ($val as $k => $v) {
                 if (isset($datas['cost'][$v['name']]) && $datas['cost'][$v['name']] != '') {
                     Tag::displayTo("cost[" . $v['name'] . "]", $datas['cost'][$v['name']]);
                 }
                 if (isset($datas['remark'][$v['name']]) && $datas['remark'][$v['name']] != '') {
                     Tag::displayTo("remark[" . $v['name'] . "]", $datas['remark'][$v['name']]);
                 }
                 if (isset($datas['limit'][$v['name']]) && $datas['limit'][$v['name']] != '') {
                     Tag::displayTo("limit[" . $v['name'] . "]", $datas['limit'][$v['name']]);
                 }
             }
         }
         Tag::displayTo("id", $Finance->id);
         $auth = $this->session->get("auth");
         if ($auth['did'] != 0) {
             Tag::setDefault("company", $auth['did']);
         }
         $this->view->setVar('did', $auth['did']);
         /*             
                     Tag::displayTo("product_types_id", $products->product_types_id);
                     Tag::displayTo("name", $products->name);
                     Tag::displayTo("price", $products->price);
                     Tag::displayTo("active", $products->active); 
                     $this->view->setVar("productTypes", ProductTypes::find());			
         */
     }
 }
Esempio n. 10
0
 function test_find()
 {
     //Arrange
     $descript = "Event Keepsakes";
     $descript2 = "Antiques";
     $test_Type = new Type($descript);
     $test_Type->save();
     $test_Type2 = new Type($descript2);
     $test_Type2->save();
     //Act
     $result = Type::find($test_Type->getId());
     //Assert
     $this->assertEquals($test_Type, $result);
 }
Esempio n. 11
0
 public function postType($type_id)
 {
     $all = Input::all();
     $rules = array('name' => 'required|min:2|max:255', 'type' => 'required|min:3|max:255');
     $validator = Validator::make($all, $rules);
     if ($validator->fails()) {
         return Redirect::to('/admin/content/' . $type_id)->withErrors($validator)->withInput()->with('error', 'Ошибка');
     }
     if (is_numeric($type_id)) {
         $post = Type::find($type_id);
     } else {
         $post = new Type();
     }
     $post->type = $all['type'];
     $post->name = $all['name'];
     $post->template = $all['template'];
     $post->title = $all['title'];
     $post->text = $all['text'];
     $post->status = isset($all['status']) ? true : false;
     $post->save();
     return Redirect::to('/admin/content/' . $type_id)->with('success', 'Изменения сохранены');
 }
Esempio n. 12
0
 public function postTypeEdit($TypeId)
 {
     $rules = array('name' => 'required|min:2|unique:type,name,' . $TypeId, 'code' => 'required|unique:type,code,' . $TypeId);
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('branch/type-edit/' . $TypeId)->withErrors($validator)->withInput();
     }
     $type = Type::find($TypeId);
     $type->name = Input::get('name');
     $type->code = Input::get('code');
     $type->day = Input::get('day');
     $type->save();
     return Redirect::to('branch/type')->with('success', '客户类型更新成功!');
 }
Esempio n. 13
0
 function type($id = FALSE)
 {
     $this->load->helper('notification');
     if ($_POST) {
         unset($_POST['send']);
         unset($_POST['_wysihtml5_mode']);
         $id = $_POST['id'];
         unset($_POST['id']);
         $ticket = Ticket::find_by_id($id);
         $attr = array('type_id' => $_POST['type_id']);
         $ticket->update_attributes($attr);
         if (!$ticket) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_assign_type_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_assign_type_success'));
         }
         redirect('tickets/view/' . $id);
     } else {
         $this->view_data['types'] = Type::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['ticket'] = Ticket::find_by_id($id);
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_type');
         $this->view_data['form_action'] = 'tickets/type';
         $this->content_view = 'tickets/_type';
     }
 }
Esempio n. 14
0
 public function actionAdd()
 {
     $type = Type::find()->all();
     return $this->render('add', ['type' => $type]);
 }
 /**
  * Import zKillboard kills for the selected systems and alliances.
  */
 public function getZkillboard($systems = '')
 {
     // If this is the initial call to the function, retrieve the list of systems from the DB.
     if ($systems == '') {
         $systems_object = Setting::where('key', 'systems')->firstOrFail();
         $systems = $systems_object->value;
     }
     // Convert the comma-seperated string into an array.
     $systems_array = explode(',', $systems);
     // If there are more systems in the list than we want to pull at once, chop off the first X and call this function again.
     while (count($systems_array) > $this->api_system_limit) {
         $this->getZkillboard(implode(',', array_splice($systems_array, 0, $this->api_system_limit)));
     }
     // Retrieve the selected alliances from the database.
     $alliances = Setting::where('key', 'alliances')->firstOrFail();
     // Build the API URL.
     $url = 'https://zkillboard.com/api/xml/losses/no-attackers/' . 'allianceID/' . preg_replace('/\\s+/', '', $alliances->value) . '/' . 'solarSystemID/' . preg_replace('/\\s+/', '', $systems) . '/';
     // Send the request.
     $response = Request::get($url)->addHeader('Accept-Encoding', 'gzip')->addHeader('User-Agent', 'Eve Traders Handbook')->send();
     if (isset($response->body) && strlen($response->body) > 0) {
         $body = simplexml_load_string(gzdecode($response->body));
         $insert_count = 0;
         // Parse the response, inserting the losses into the database.
         foreach ($body->result->rowset->row as $row) {
             // First check whether this kill has not already been recorded.
             $kill = Kill::find($row['killID']);
             if (!isset($kill->killID)) {
                 // Create and save the new kill record.
                 $kill = new Kill();
                 $kill->killID = $row['killID'];
                 $kill->solarSystemID = $row['solarSystemID'];
                 $kill->characterID = $row->victim['characterID'];
                 $kill->characterName = $row->victim['characterName'];
                 $kill->allianceID = $row->victim['allianceID'];
                 $kill->corporationID = $row->victim['corporationID'];
                 $kill->shipTypeID = $row->victim['shipTypeID'];
                 $kill->killTime = $row['killTime'];
                 $kill->save();
                 $insert_count++;
                 // Insert the alliance information into the database unless it already exists.
                 $alliance = Alliance::find($kill->allianceID);
                 if (!isset($alliance->id)) {
                     $alliance = new Alliance();
                     $alliance->id = $kill->allianceID;
                     $alliance->allianceName = $row->victim['allianceName'];
                     $alliance->save();
                 }
                 // Insert the corporation information into the database unless it already exists.
                 $corporation = Corporation::find($kill->corporationID);
                 if (!isset($corporation->id)) {
                     $corporation = new Corporation();
                     $corporation->id = $kill->corporationID;
                     $corporation->corporationName = $row->victim['corporationName'];
                     $corporation->save();
                 }
                 // Insert the ship type that was lost into the database unless it already exists.
                 $ship = Ship::find($kill->shipTypeID);
                 $type = Type::find($kill->shipTypeID);
                 if (!isset($ship->id)) {
                     $ship = new Ship();
                     $ship->id = $kill->shipTypeID;
                     $ship->shipName = $type->typeName;
                     $ship->save();
                 }
                 // Insert the ship loss into the items database as well.
                 if (stristr($ship->shipName, 'Capsule') === FALSE) {
                     $item = new Item();
                     $item->killID = $row['killID'];
                     $item->typeID = $kill->shipTypeID;
                     $item->typeName = $type->typeName;
                     $item->categoryName = $type->group->category['categoryName'];
                     $item->metaGroupName = isset($type->metaType->metaGroup['metaGroupName']) ? $type->metaType->metaGroup['metaGroupName'] : '';
                     $item->allowManufacture = 1;
                     $item->qty = 1;
                     $item->save();
                 }
                 // Add the category to the list of filters available on the site.
                 $filter = Filter::find($type->group->category['categoryID']);
                 if (!isset($filter->categoryID)) {
                     $filter = new Filter();
                     $filter->categoryID = $type->group->category['categoryID'];
                     $filter->categoryName = $type->group->category['categoryName'];
                     $filter->iconID = $type->group->category['iconID'];
                     $filter->save();
                 }
                 // Loop through the items lost in the kill. Insert each one into the items table.
                 if (isset($row->rowset->row)) {
                     foreach ($row->rowset->row as $loss) {
                         $typeID = (int) $loss['typeID'];
                         $item = Item::where('typeID', '=', $typeID)->first();
                         // If this item already exists in the items table, we don't need to re-query all the additional
                         // information, we can just copy it from an existing row.
                         if (isset($item)) {
                             // This type has already been seen. Duplicate the record and save the new instance.
                             $clone = new Item();
                             $clone = $item->replicate();
                             // Update the right killID and quantity, and unset the primary key and date columns.
                             $clone->killID = $row['killID'];
                             $clone->qty = $loss['qtyDropped'] + $loss['qtyDestroyed'];
                             unset($clone->id);
                             unset($clone->created_at);
                             unset($clone->updated_at);
                             // Save the cloned row.
                             $clone->save();
                         } else {
                             // This is a never-before-seen lost item. Create a new row and look up all the related details.
                             $item = new Item();
                             $type = Type::find($typeID);
                             $item->killID = (int) $row['killID'];
                             $item->typeID = $typeID;
                             $item->typeName = $type->typeName;
                             $item->categoryName = $type->group->category['categoryName'];
                             $metaGroupName = isset($type->metaType->metaGroup['metaGroupName']) ? $type->metaType->metaGroup['metaGroupName'] : '';
                             if ($metaGroupName == 'Tech I' || $metaGroupName == '') {
                                 $metaLevel = DB::table('dgmTypeAttributes')->where('typeID', $typeID)->where('attributeID', 633)->first();
                                 if (isset($metaLevel)) {
                                     $metaGroupName = 'Meta ';
                                     $metaGroupName .= isset($metaLevel->valueInt) ? $metaLevel->valueInt : $metaLevel->valueFloat;
                                 }
                             }
                             $item->metaGroupName = $metaGroupName;
                             $blueprint = Type::where('typeName', $type->typeName . ' Blueprint')->count();
                             if ($blueprint > 0) {
                                 $item->allowManufacture = 1;
                             }
                             $item->qty = $loss['qtyDropped'] + $loss['qtyDestroyed'];
                             $item->save();
                             // Add the category to the list of filters available on the site.
                             $filter = Filter::find($type->group->category['categoryID']);
                             if (!isset($filter->categoryID)) {
                                 $filter = new Filter();
                                 $filter->categoryID = $type->group->category['categoryID'];
                                 $filter->categoryName = $type->group->category['categoryName'];
                                 $filter->iconID = $type->group->category['iconID'];
                                 $filter->save();
                             }
                         }
                     }
                 }
             }
         }
         echo "Inserted {$insert_count} new kills! ";
     } else {
         echo "No response received from zKillboard API.";
     }
 }
Esempio n. 16
0
 function ticket()
 {
     $this->view_data['breadcrumb'] = $this->lang->line('application_ticket');
     $this->view_data['breadcrumb_id'] = "ticket";
     $this->view_data['imap_loaded'] = false;
     if (extension_loaded('mysql')) {
         $this->view_data['imap_loaded'] = true;
     }
     if ($_POST) {
         unset($_POST['send']);
         if (!isset($_POST['ticket_config_active'])) {
             $_POST['ticket_config_active'] = "0";
         }
         if (!isset($_POST['ticket_config_delete'])) {
             $_POST['ticket_config_delete'] = "0";
         }
         if (!isset($_POST['ticket_config_ssl'])) {
             $_POST['ticket_config_ssl'] = "0";
         }
         if (!isset($_POST['ticket_config_imap'])) {
             $_POST['ticket_config_imap'] = "0";
         }
         $settings = Setting::first();
         $settings->update_attributes($_POST);
         if ($settings) {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_settings_success'));
             redirect('settings/ticket');
         } else {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_settings_error'));
             redirect('settings/ticket');
         }
     } else {
         $this->view_data['settings'] = Setting::first();
         $this->view_data['types'] = Type::find('all', array('conditions' => array('inactive = ?', '0')));
         $this->view_data['queues'] = Queue::find('all', array('conditions' => array('inactive = ?', '0')));
         $this->view_data['owners'] = User::find('all', array('conditions' => array('status = ?', 'active')));
         $this->view_data['form_action'] = 'settings/ticket';
         $this->content_view = 'settings/ticket';
     }
 }
Esempio n. 17
0
 public function getShortTypeAttribute()
 {
     return Type::find($this->type_id)->short_name;
 }
Esempio n. 18
0
 public function admin_delete_type($admin)
 {
     if (!isset($_GET['id'])) {
         error(__("Error"), __("No type ID specified.", "extend"));
     }
     $type = new Type($_GET['id']);
     if ($type->no_results) {
         error(__("Error"), __("Invalid type ID specified.", "extend"));
     }
     if (!$type->deletable()) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this type.", "extend"));
     }
     $admin->display("delete_type", array("type" => $type, "types" => Type::find(array("where" => array("id not" => $type->id)))), _f("Delete Type &#8220;%s&#8221;", array(fix($type->name)), "extend"));
 }
Esempio n. 19
0
$app->get("/types", function () use($app) {
    return $app['twig']->render('types.html.twig', array('types' => Type::getAll()));
});
$app->get("/types/{id}", function ($id) use($app) {
    $type = Type::find($id);
    return $app['twig']->render('types.html.twig', array('types' => $type, 'animals' => $type->getAnimals()));
});
$app->post("/animals", function () use($app) {
    $name = $_POST['name'];
    $gender = $_POST['gender'];
    $breed = $_POST['breed'];
    $age = $_POST['age'];
    $type_id = $_POST['type_id'];
    $animal = new Animal($name, $gender, $breed, $age, $type_id, $id = null);
    $animal->save();
    $type = Type::find($type_id);
    return $app['twig']->render('types.html.twig', array('types' => $type, 'animals' => Animal::getAll()));
});
$app->post("/types", function () use($app) {
    $type = new Type($_POST['name']);
    $type->save();
    return $app['twig']->render('index.html.twig', array('types' => Type::getAll()));
});
$app->post("/delete_types", function () use($app) {
    Animal::deleteAll();
    Type::deleteAll();
    return $app['twig']->render('index.html.twig', array('types' => Type::getAll()));
});
return $app;
?>
	
Esempio n. 20
0
 public function actionDelete()
 {
     $request = Yii::app()->getRequest();
     $id = trim($request->getParam("id"));
     if ($id) {
         try {
             $rs = new Type();
             $row = $rs->find('tid=:tid', array(':tid' => $id));
             $row->delete();
             $this->redirect(array('list'));
         } catch (Exception $e) {
             throw Exception($e);
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /clienttype/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $client = Type::find($id)->delete();
     if (is_null($client)) {
         $class = 'error';
         $message = 'Record does not exist.';
     } else {
         $class = 'success';
         $message = 'Record successfully deleted.';
     }
     return Redirect::route('client.index')->with('class', $class)->with('message', $message);
 }
 /**
  * Display detailed information about a specific item, including the icon,
  * description, price to buy in trade hubs and locally, and manufacturing costs
  * based on mineral prices in the local area.
  */
 public function item($id = NULL)
 {
     // Retrieve the basic information about this item.
     $type = Type::where('typeID', $id)->firstOrFail();
     // If material efficiency was updated, save to the database and set a local variable.
     $material_efficiency = $type->materialEfficiency;
     if (!isset($material_efficiency)) {
         $material_efficiency = new MaterialEfficiency();
         $material_efficiency->typeID = $id;
         $material_efficiency->materialEfficiency = 0;
     }
     if (Input::has('me')) {
         $material_efficiency->materialEfficiency = (int) Input::get('me');
     }
     // Save the updated material efficiency figure.
     $type->materialEfficiency()->save($material_efficiency);
     // Calculate volume if we need to use shipping data.
     $shipping_cost = Setting::where('key', 'shipping_cost')->first();
     $shipping_cost_to_include = 0;
     if ($shipping_cost->value > 0) {
         // If volume is below 1000, we assume it's not a ship hull and use the base volume.
         if ($type->volume < 1000) {
             $shipping_cost_to_include = $shipping_cost->value * $type->volume;
         } else {
             // For larger volumes, we need to use static values for ship types.
             switch ($type->groupID) {
                 case 31:
                     $shipping_cost_to_include = $shipping_cost->value * 500;
                     break;
                 case 25:
                 case 237:
                 case 324:
                 case 830:
                 case 831:
                 case 834:
                 case 893:
                     $shipping_cost_to_include = $shipping_cost->value * 2500;
                     break;
                 case 463:
                 case 543:
                     $shipping_cost_to_include = $shipping_cost->value * 3750;
                     break;
                 case 420:
                 case 541:
                     $shipping_cost_to_include = $shipping_cost->value * 5000;
                     break;
                 case 26:
                 case 358:
                 case 832:
                 case 833:
                 case 894:
                     $shipping_cost_to_include = $shipping_cost->value * 10000;
                     break;
                 case 28:
                     $shipping_cost_to_include = $shipping_cost->value * 20000;
                     break;
                 case 27:
                 case 381:
                     $shipping_cost_to_include = $shipping_cost->value * 50000;
                     break;
             }
         }
     }
     // Load the 64x64 icon to display.
     $icon = '';
     $ship = Ship::where('id', $id)->get();
     if (count($ship)) {
         $icon = 'https://image.eveonline.com/Render/' . $id . '_128.png';
     } elseif ($type->Group->Icon) {
         $icon = str_replace('_', '_64_', $type->MarketGroup->Icon->iconFile);
         $icon = preg_replace('/^0/', '', $icon);
         $icon = preg_replace('/0(.)$/', '$1', $icon);
         $icon = 'eve/items/' . $icon . '.png';
     }
     // Retrieve the current price ranges this item sells for.
     $response = API::eveCentral(array($id), Setting::where('key', 'home_region_id')->pluck('value'));
     $local_price = $response[$id];
     // Tech II items need to be treated differently.
     $t2_options = array();
     if ($type->metaType && $type->metaType->metaGroup && $type->metaType->metaGroup['metaGroupName'] == 'Tech II') {
         // Retrieve an array of different possibilities for decryptors.
         $tech_two = TechII::getInventionFigures($type);
         // For each decryptor, show the potential profit.
         $total_price = 1000000000;
         foreach ($tech_two as $decryptor) {
             // Default max runs is 10, add any modifier.
             $max_runs = 10;
             if (isset($decryptor['max_run_modifier'])) {
                 $max_runs += $decryptor['max_run_modifier'];
             }
             // Based on the chance of success, how many T2 items on average will be produced per run?
             $chance_of_success = $decryptor['chance_of_success'] / 100;
             $t2_items_per_blueprint = $max_runs * $chance_of_success;
             // Calculate the cost of manufacturing that many T2 items.
             $manufacturing_cost_per_blueprint = $t2_items_per_blueprint * ($decryptor['t2_manufacture_price'] * (100 - $decryptor['me_modifier']) / 100);
             $total_cost = $decryptor['invention_price'] + $manufacturing_cost_per_blueprint;
             $cost_per_unit = $total_cost / $t2_items_per_blueprint;
             $t2_options[] = array("typeName" => $decryptor['typeName'], "cost" => $cost_per_unit);
             if ($cost_per_unit < $total_price) {
                 $total_price = $cost_per_unit;
             }
         }
         $manufacturing = NULL;
     } else {
         // If the meta level of this item is not Meta 0, we don't need to pull the manufacture price.
         $item = Item::where('typeID', $id)->first();
         if ($item->allowManufacture == 1) {
             // Get a list of what is needed to manufacture the item.
             $manufacturing = array();
             $total_price = 0;
             $type_materials = DB::table('invTypeMaterials')->where('typeID', $id)->get();
             $types = array();
             $jita_types = array();
             // Loop through all the materials. For each one, add it to an array we will use to show manufacturing details.
             foreach ($type_materials as $material) {
                 // Build an array for the eve-central API call.
                 $types[] = $material->materialTypeID;
                 // Build an array for the eventual output.
                 $manufacturing[$material->materialTypeID] = (object) array("typeName" => Type::find($material->materialTypeID)->typeName, "qty" => $material->quantity * (1 - $material_efficiency->materialEfficiency / 100), "price" => 0, "jita" => FALSE);
             }
             // Make an API call to get the local price of materials.
             $api = API::eveCentral($types, $home_region_id = Setting::where('key', 'home_region_id')->pluck('value'));
             // Loop through each returned price and update the data in the manufacturing array.
             foreach ($api as $api_result) {
                 if ($api_result->median != 0) {
                     $manufacturing[$api_result->id]->price = $manufacturing[$api_result->id]->qty * $api_result->median;
                     $total_price += $manufacturing[$api_result->id]->price;
                 } else {
                     // Build an array of types to check prices at Jita.
                     $jita_types[] = $api_result->id;
                 }
             }
             // If we need to check prices at Jita, make another API call.
             if (count($jita_types)) {
                 $api = API::eveCentral($jita_types, NULL, 30000142);
                 // Loop through each returned price and update the data in the manufacturing array.
                 foreach ($api as $api_result) {
                     $manufacturing[$api_result->id]->price = $manufacturing[$api_result->id]->qty * $api_result->median;
                     $manufacturing[$api_result->id]->jita = TRUE;
                     $total_price += $manufacturing[$api_result->id]->price;
                 }
             }
             $potential_profits = NULL;
         } else {
             $manufacturing = NULL;
             $total_price = 999999999;
         }
     }
     // Retrieve current prices of the module in notable trade hubs.
     $jita = API::eveCentral($id, NULL, 30000142);
     $prices[] = (object) array("solarSystemName" => "Jita", "median" => $jita[$id]->median);
     $amarr = API::eveCentral($id, NULL, 30002187);
     $prices[] = (object) array("solarSystemName" => "Amarr", "median" => $amarr[$id]->median);
     $importCostToUse = (int) $jita[$id]->median < (int) $amarr[$id]->median ? $jita[$id]->median : $amarr[$id]->median;
     if ($shipping_cost_to_include) {
         $importCostToUse = $importCostToUse + $shipping_cost_to_include;
     }
     // Cache the industry and import potential profits for the item.
     $profit = $type->profit;
     if (!isset($profit)) {
         $profit = new Profit();
         $profit->typeID = $id;
     }
     $profit->manufactureCost = round($total_price);
     $profit->profitIndustry = round($local_price->median - $total_price);
     $profit->profitImport = round($local_price->median - $importCostToUse);
     // Save the cached potential profit figure.
     $type->profit()->save($profit);
     $profitToUse = $profit->profitIndustry > $profit->profitImport ? $profit->profitIndustry : $profit->profitImport;
     $costToUse = $profit->profitIndustry > $profit->profitImport ? $total_price : $importCostToUse;
     return View::make('item')->with('type', $type)->with('icon', $icon)->with('local_price', $local_price)->with('prices', $prices)->with('shipping_cost', $shipping_cost_to_include)->with('manufacturing', $manufacturing)->with('t2_options', $t2_options)->with('total_price', $total_price)->with('profit', $profit)->with('profitToUse', $profitToUse)->with('costToUse', $costToUse)->with('material_efficiency', $material_efficiency);
 }