public function action_delete($id) { if (Session::has('id')) { $account = Account::find(Session::get('id')); $location = Location::find($id); $owner = Account::find($location->account_id); if ($account->id == $owner->id) { $listings = Listing::where_location_id($location->id); // foreach($listings as $listing) // { // $images = Image::where_listing_id($listing->id); // foreach($images as $image) // { // $image->delete(); // } // $listing->delete(); // } $location->delete(); return Redirect::to('/account/myLocations/'); } else { return Redirect::to('/'); } } else { return Redirect::to('/'); } }
static function getObjectStructure() { global $user; //Load Libraries for lookup values $location = new Location(); $location->orderBy('displayName'); if ($user->hasRole('libraryAdmin')) { $homeLibrary = Library::getPatronHomeLibrary(); $location->libraryId = $homeLibrary->libraryId; } $location->find(); $locationList = array(); while ($location->fetch()) { $locationList[$location->locationId] = $location->displayName; } require_once ROOT_DIR . '/sys/Browse/BrowseCategory.php'; $browseCategories = new BrowseCategory(); $browseCategories->orderBy('label'); $browseCategories->find(); $browseCategoryList = array(); while ($browseCategories->fetch()) { $browseCategoryList[$browseCategories->textId] = $browseCategories->label . " ({$browseCategories->textId})"; } $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'locationId' => array('property' => 'locationId', 'type' => 'enum', 'values' => $locationList, 'label' => 'Location', 'description' => 'A link to the location which the browse category belongs to'), 'browseCategoryTextId' => array('property' => 'browseCategoryTextId', 'type' => 'enum', 'values' => $browseCategoryList, 'label' => 'Browse Category', 'description' => 'The browse category to display '), 'weight' => array('property' => 'weight', 'type' => 'numeric', 'label' => 'Weight', 'weight' => 'Defines how lists are sorted within the widget. Lower weights are displayed to the left of the screen.', 'required' => true)); foreach ($structure as $fieldName => $field) { $field['propertyOld'] = $field['property'] . 'Old'; $structure[$fieldName] = $field; } return $structure; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Location::got_property($id) == false) { $this->location->find($id)->delete(); } return Redirect::route('admin.locations.index'); }
public function getCountryList() { /* Start here set the country list */ App::import("Model", "Location"); $location = new Location(); $options = array('fields' => array('Location.county_name')); return $getLocationArray = $location->find('list', $options); }
/** * Show the form for adding sightings. * * @param int $id * @return View */ public function sightings($id) { // retrieve current sightings $sightings = DB::select('CALL proc_listSightingsForTrip(?);', [$id]); $trip = Trip::find($id); $location = Location::find($trip->location_id); return View::make('admin/trips/sightings')->with(['sightings' => $sightings])->with(['location' => $location])->with(['trip' => $trip]); }
public function getLocationDatabase() { $locData = Location::find('all'); $data = array(); foreach ($locData as $location) { $data[] = array('prefix' => $location->prefix, 'shortname' => $location->name, 'name' => $location->name . ', ' . $location->country, 'lat' => $location->lat, 'lon' => $location->lon, 'pop' => $location->population); } $this->output = $data; }
public function update($id) { $location = Location::find($id); $location->code = Input::get('code'); $location->name = Input::get('name'); $location->address = Input::get('address'); $location->contact = Input::get('contact'); $location->save(); Session::flash('message', 'Sukses mengupdate cabang!'); }
public function postMobile() { $donations = Input::get('mobile_campaign_id'); foreach ($donations as $mobileID) { $mobile = Location::find($mobileID); } //Session::flash('success', 'Successfully selected mobiles!'); //return Redirect::action('DonationController@getMobiles'); return Redirect::route('donation.getMobile'); }
public function execute($lastRunDt = null) { $config = Zend_Registry::get('config'); $checkDtStart = new Zend_Date($this->_lastRunDt); $checkDtStart->subHour($config->user->numHoursEvaluationReminder->val); $checkDtEnd = new Zend_Date(); $checkDtEnd->subHour($config->user->numHoursEvaluationReminder->val); $event = new Event(); $events = $event->getEvents(null, null, null, $checkDtStart->getTimestamp(), $checkDtEnd->getTimestamp(), 'open'); $location = new Location(); $workshop = new Workshop(); $instructor = new Event_Instructor(); $attendee = new Event_Attendee(); $eu = new Evaluation_User(); foreach ($events as $e) { $startDt = strtotime($e->date . ' ' . $e->startTime); $endDt = strtotime($e->date . ' ' . $e->endTime); if ($checkDtStart->getTimestamp() < $endDt && $checkDtEnd->getTimestamp() >= $endDt) { $evalAvailableDt = new Zend_Date($endDt); $evalAvailableDt->addHour($config->user->numHoursEvaluationAvailability->val); if ($evalAvailableDt->getTimestamp() > time()) { $taken = $eu->getCompleted($e->eventId); $thisLocation = $location->find($e->locationId); if (is_null($thisLocation)) { throw new Ot_Exception_Data('msg-error-noLocation'); } $thisWorkshop = $workshop->find($e->workshopId); if (is_null($thisWorkshop)) { throw new Ot_Exception_Data('msg-error-noWorkshop'); } $instructors = $instructor->getInstructorsForEvent($e->eventId); $instructorNames = array(); $instructorEmails = array(); foreach ($instructors as $i) { $instructorNames[] = $i['firstName'] . ' ' . $i['lastName']; $instructorEmails[] = $i['emailAddress']; } $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails)); $attending = $attendee->getAttendeesForEvent($e->eventId, 'attending'); foreach ($attending as $a) { if ($a['attended'] == 1 && !in_array($a['accountId'], $taken)) { $trigger = new Ot_Trigger(); $trigger->setVariables($data); $trigger->accountId = $a['accountId']; $trigger->studentEmail = $a['emailAddress']; $trigger->studentName = $a['firstName'] . ' ' . $a['lastName']; $trigger->studentUsername = $a['username']; $trigger->dispatch('Event_Evaluation_Reminder'); } } } } } }
/** * Display the specified resource. * GET /location/{id} * * @param int $id * @return Response */ public function show($id) { $CalendarEvent = CalendarEvent::find($id); $EventID = $CalendarEvent->location_id; $Location = Location::find($EventID); if (!$CalendarEvent) { Session::flash('errorMessage', "Blog post was not found"); App::abort(404); } Log::info(Input::all()); return View::make('/event')->with(array('event' => $CalendarEvent, 'location' => $Location)); }
public function action_delete() { if (Session::has('id') && Auth::check() && Input::has('file') && Input::has('listing_id')) { $account = Account::find(Session::get('id')); $listing = Listing::find(Input::get('listing_id')); $location = Location::find($listing->location_id); if ($account->id == $location->account_id) { unlink(Input::get('file')); } else { die("Image does not belogn to user"); } } }
public function remove($id) { $adminId = Session::get('admin_id'); if (!isset($adminId)) { return json_encode(array('message' => 'not logged')); } $location = Location::find($id); if (is_null($location)) { return json_encode(array('message' => 'invalid')); } else { $location->status = 'removed'; $location->save(); return json_encode(array('message' => 'done')); } }
/** * Store a newly created stock in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Stock::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $item_id = Input::get('item'); $location_id = Input::get('location'); $item = Item::findOrFail($item_id); $location = Location::find($location_id); $quantity = Input::get('quantity'); $date = Input::get('date'); Stock::addStock($item, $location, $quantity, $date); return Redirect::route('stocks.index')->withFlashMessage('stock has been successfully updated!'); }
/** * Request a specific Inventory from View Page * * @param Request $request (Ajax) * @param Inventory $item * * @return array */ public function request(Request $request, Inventory $item) { /** * If stock don't exist for this item, create it in location 1 (Nonlocated) * with zero quantity. * If stock exist, fetch the stock from record. */ if (count($item->stocks) == 0) { $stock = $item->newStockOnLocation(Location::find(1)); $stock->quantity = 0; $stock->save(); } else { $stock = InventoryStock::where('inventory_id', $item->id)->first(); } // Create new Request Transaction (order-requested) $transaction = $stock->newTransaction(); $transaction->requested($request->quantity); return $transaction; }
function getObjectStructure() { //Look lookup information for display in the user interface $location = new Location(); $location->orderBy('displayName'); $location->find(); $locationList = array(); $locationLookupList = array(); $locationLookupList[-1] = '<No Nearby Location>'; while ($location->fetch()) { $locationLookupList[$location->locationId] = $location->displayName; $locationList[$location->locationId] = clone $location; } $structure = array('ip' => array('property' => 'ip', 'type' => 'text', 'label' => 'IP Address', 'description' => 'The IP Address to map to a location formatted as xxx.xxx.xxx.xxx/mask'), 'location' => array('property' => 'location', 'type' => 'text', 'label' => 'Display Name', 'description' => 'Descriptive information for the IP Address for internal use'), 'locationid' => array('property' => 'locationid', 'type' => 'enum', 'values' => $locationLookupList, 'label' => 'Location', 'description' => 'The Location which this IP address maps to')); foreach ($structure as $fieldName => $field) { $field['propertyOld'] = $field['property'] . 'Old'; $structure[$fieldName] = $field; } return $structure; }
static function getObjectStructure() { global $user; $location = new Location(); $location->orderBy('displayName'); if ($user->hasRole('libraryAdmin')) { $homeLibrary = Library::getPatronHomeLibrary(); $location->libraryId = $homeLibrary->libraryId; } $location->find(); while ($location->fetch()) { $locationList[$location->locationId] = $location->displayName; } $structure = parent::getObjectStructure(); $structure['locationId'] = array('property' => 'locationId', 'type' => 'enum', 'values' => $locationList, 'label' => 'Location', 'description' => 'The id of a location'); foreach ($structure as $fieldName => $field) { $field['propertyOld'] = $field['property'] . 'Old'; $structure[$fieldName] = $field; } return $structure; }
static function getObjectStructure() { $location = new Location(); $location->orderBy('displayName'); $location->find(); $locationList = array(); while ($location->fetch()) { $locationList[$location->locationId] = $location->displayName; } $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); $time = array('01:00', '01:30', '02:00', '02:30', '03:00', '03:30', '04:00', '04:30', '05:00', '05:30', '06:00', '06:30', '07:00', '07:30', '08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00', '20:30', '21:00', '21:30', '22:00', '22:30', '23:00', '23:30'); $timeList = array(); foreach ($time as $t) { $timeList[$t] = $t; } $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'locationId' => array('property' => 'locationId', 'type' => 'enum', 'values' => $locationList, 'label' => 'Location', 'description' => 'The library location.'), 'day' => array('property' => 'day', 'type' => 'enum', 'values' => $days, 'label' => 'Day of Week', 'description' => 'The day of the week 0 to 6 (0 = Sunday to 6 = Saturday)'), 'closed' => array('property' => 'closed', 'type' => 'checkbox', 'label' => 'Closed', 'description' => 'Check to indicate that the library is closed on this day.'), 'open' => array('property' => 'open', 'type' => 'enum', 'values' => $timeList, 'label' => 'Opening Hour', 'description' => 'The opening hour. Use 24 hour format HH:MM, eg: 08:30'), 'close' => array('property' => 'close', 'type' => 'enum', 'values' => $timeList, 'label' => 'Closing Hour', 'description' => 'The closing hour. Use 24 hour format HH:MM, eg: 16:30')); foreach ($structure as $fieldName => $field) { $field['propertyOld'] = $field['property'] . 'Old'; $structure[$fieldName] = $field; } return $structure; }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // $validator = $this->validate(); if ($validator->fails()) { return Redirect::back()->withErrors($validator->messages())->withInput(Input::all()); } $type = Input::get('type'); $product = Product::find(Input::get('product_id')); $location = Location::find(Input::get('location_id')); $quantity = Input::get('quantity'); $adjustment_date = Input::get('adjustment_date'); $description = Input::get('description'); DB::beginTransaction(); $adjustment = new Adjustment(); // Record details in adjustment table // Type [1 : Positive] [2 : Negative] $adjustment->type = $type; $adjustment->adjustment_date = $adjustment_date; $adjustment->description = $description; $adjustment->save(); // Store other details in a new array $extra = array('product-id ' => $product->id, 'quantity' => $quantity, 'location_id' => $location->id); // Get the current adjustment id; //Update records in the adjustment_products table //If type : POSITIVE // 1.Find the correct record and Increment the product qty in location_products table // 2.Update item_in table //If type : NEGATIVE // 1.Find the correct record and Decrement the product qty in location_products table // 2.Update item_out table $response = Event::fire('adjustment.create', array($adjustment, $extra)); DB::commit(); print_r($response); exit; Session::flash('success', 'Successfully created donation!'); return Redirect::route('adjustment.index'); }
public function execute($lastRunDt = null) { $config = Zend_Registry::get('config'); $event = new Event(); $events = $event->getEvents(null, null, null, time(), null, 'open'); $location = new Location(); $workshop = new Workshop(); $instructor = new Event_Instructor(); $checkDt = new Zend_Date($this->_lastRunDt); $checkDt->addHour($config->user->numHoursLowAttendanceNotification->val); foreach ($events as $e) { if ($e->roleSize < $e->minSize) { $startDt = strtotime($e->date . ' ' . $e->startTime); $endDt = strtotime($e->date . ' ' . $e->endTime); if ($checkDt->getTimestamp() > $startDt && $this->_lastRunDt < $startDt) { $thisLocation = $location->find($e->locationId); if (is_null($thisLocation)) { throw new Ot_Exception_Data('msg-error-noLocation'); } $thisWorkshop = $workshop->find($e->workshopId); if (is_null($thisWorkshop)) { throw new Ot_Exception_Data('msg-error-noWorkshop'); } $instructors = $instructor->getInstructorsForEvent($e->eventId); $instructorNames = array(); $instructorEmails = array(); foreach ($instructors as $i) { $instructorNames[] = $i['firstName'] . ' ' . $i['lastName']; $instructorEmails[] = $i['emailAddress']; } $data = array('workshopName' => $thisWorkshop->title, 'workshopDate' => date('m/d/Y', $startDt), 'workshopStartTime' => date('g:i a', $startDt), 'workshopEndTime' => date('g:i a', $endDt), 'workshopMinimumEnrollment' => $e->minSize, 'workshopCurrentEnrollment' => $e->roleSize, 'locationName' => $thisLocation->name, 'locationAddress' => $thisLocation->address, 'instructorNames' => implode(', ', $instructorNames), 'instructorEmails' => implode(', ', $instructorEmails)); $trigger = new Ot_Trigger(); $trigger->setVariables($data); $trigger->dispatch('Event_LowAttendance'); } } } }
public static function findInLocation($lat, $lng, $max_distance = 25, $units = 'miles', $paginate = true) { switch ($units) { case 'miles': //radius of the great circle in miles $gr_circle_radius = 3959; break; case 'kilometers': //radius of the great circle in kilometers $gr_circle_radius = 6371; break; } $haversine = '(' . $gr_circle_radius . ' * acos(cos(radians(' . $lat . ')) * cos(radians(lat)) * cos(radians(lng) - radians(' . $lng . ')) + sin(radians(' . $lat . ')) * sin(radians(lat))))'; $radius = 1; $locations = DB::table('locations')->select(array('*', DB::raw($haversine . ' as distance')))->orderBy('distance', 'ASC')->having('distance', '<=', $max_distance)->having('locationable_type', '=', 'Spot')->get(); $spots = []; foreach ($locations as $loc) { $location = Location::find($loc->id); if ($location->locationable && $location->locationable->status == 'Publish') { array_push($spots, $location->locationable); } } $collection = new Illuminate\Support\Collection($spots); $collection->sort(function ($a, $b) { return $a->created_at->lt($b->created_at); }); if ($paginate) { $page = 1; if (Input::has('page')) { $page = Input::get('page'); } $perPage = 200; $offset = ($page - 1) * $perPage; return Paginator::make($collection->slice($offset, $perPage, true)->all(), $collection->count(), $perPage); } return $collection; }
function launch() { global $configArray; global $interface; global $user; //Load status information $materialsRequestStatus = new MaterialsRequestStatus(); $materialsRequestStatus->orderBy('isDefault DESC, isOpen DESC, description ASC'); if ($user->hasRole('library_material_requests')) { $homeLibrary = Library::getPatronHomeLibrary(); $materialsRequestStatus->libraryId = $homeLibrary->libraryId; } $materialsRequestStatus->find(); $availableStatuses = array(); $defaultStatusesToShow = array(); while ($materialsRequestStatus->fetch()) { $availableStatuses[$materialsRequestStatus->id] = $materialsRequestStatus->description; if ($materialsRequestStatus->isOpen == 1 || $materialsRequestStatus->isDefault == 1) { $defaultStatusesToShow[] = $materialsRequestStatus->id; } } $interface->assign('availableStatuses', $availableStatuses); if (isset($_REQUEST['statusFilter'])) { $statusesToShow = $_REQUEST['statusFilter']; } else { $statusesToShow = $defaultStatusesToShow; } $interface->assign('statusFilter', $statusesToShow); //Get a list of users that have requests open $materialsRequest = new MaterialsRequest(); $materialsRequest->joinAdd(new User()); $materialsRequest->joinAdd(new MaterialsRequestStatus()); $materialsRequest->selectAdd(); $materialsRequest->selectAdd('COUNT(materials_request.id) as numRequests'); $materialsRequest->selectAdd('user.id as userId, status, description, user.firstName, user.lastName, user.cat_username, user.cat_password'); if ($user->hasRole('library_material_requests')) { //Need to limit to only requests submitted for the user's home location $userHomeLibrary = Library::getPatronHomeLibrary(); $locations = new Location(); $locations->libraryId = $userHomeLibrary->libraryId; $locations->find(); $locationsForLibrary = array(); while ($locations->fetch()) { $locationsForLibrary[] = $locations->locationId; } $materialsRequest->whereAdd('user.homeLocationId IN (' . implode(', ', $locationsForLibrary) . ')'); } $statusSql = ""; foreach ($statusesToShow as $status) { if (strlen($statusSql) > 0) { $statusSql .= ","; } $statusSql .= "'" . $materialsRequest->escape($status) . "'"; } $materialsRequest->whereAdd("status in ({$statusSql})"); $materialsRequest->groupBy('userId, status'); $materialsRequest->find(); $userData = array(); while ($materialsRequest->fetch()) { if (!array_key_exists($materialsRequest->userId, $userData)) { $userData[$materialsRequest->userId] = array(); $userData[$materialsRequest->userId]['firstName'] = $materialsRequest->firstName; $userData[$materialsRequest->userId]['lastName'] = $materialsRequest->lastName; $barcodeProperty = $configArray['Catalog']['barcodeProperty']; $userData[$materialsRequest->userId]['barcode'] = $materialsRequest->{$barcodeProperty}; $userData[$materialsRequest->userId]['totalRequests'] = 0; $userData[$materialsRequest->userId]['requestsByStatus'] = array(); } $userData[$materialsRequest->userId]['requestsByStatus'][$materialsRequest->description] = $materialsRequest->numRequests; $userData[$materialsRequest->userId]['totalRequests'] += $materialsRequest->numRequests; } $interface->assign('userData', $userData); //Get a list of all of the statuses that will be shown $statuses = array(); foreach ($userData as $userInfo) { foreach ($userInfo['requestsByStatus'] as $status => $numRequests) { $statuses[$status] = translate($status); } } $interface->assign('statuses', $statuses); //Check to see if we are exporting to Excel if (isset($_REQUEST['exportToExcel'])) { $this->exportToExcel($userData, $statuses); } $interface->setTemplate('userReport.tpl'); $interface->setPageTitle('Materials Request User Report'); $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl'); $interface->display('layout.tpl'); }
/** * Load status (holdings) for a record and filter them based on the logged in user information. * * Format of return array is: * key = {section#}{location}-### where ### is the holding iteration * * value = array ( * id = The id of the bib * number = The position of the holding within the original list of holdings * section = A description of the section * sectionId = a numeric id of the section for sorting * type = holding * status * statusfull * availability * holdable * nonHoldableReason * reserve * holdQueueLength * duedate * location * libraryDisplayName * locationCode * locationLink * callnumber * link = array * linkText * isDownload * ) * * Includes both physical titles as well as titles on order * * @param string $id the id of the record * @return array A list of holdings for the record */ public function getHolding($id) { if (array_key_exists($id, HorizonAPI::$loadedStatus)) { return HorizonAPI::$loadedStatus[$id]; } global $configArray; global $library; //Get location information so we can put things into sections global $locationSingleton; /** @var $locationSingleton Location */ $physicalLocation = $locationSingleton->getPhysicalLocation(); if ($physicalLocation != null) { $physicalBranch = $physicalLocation->holdingBranchLabel; } else { $physicalBranch = ''; } $homeBranch = ''; $homeBranchId = 0; $nearbyBranch1 = ''; $nearbyBranch1Id = 0; $nearbyBranch2 = ''; $nearbyBranch2Id = 0; //Set location information based on the user login. This will override information based if (isset($user) && $user != false) { $homeBranchId = $user->homeLocationId; $nearbyBranch1Id = $user->myLocation1Id; $nearbyBranch2Id = $user->myLocation2Id; } else { //Check to see if the cookie for home location is set. if (isset($_COOKIE['home_location']) && is_numeric($_COOKIE['home_location'])) { $cookieLocation = new Location(); $locationId = $_COOKIE['home_location']; $cookieLocation->whereAdd("locationId = '{$locationId}'"); $cookieLocation->find(); if ($cookieLocation->N == 1) { $cookieLocation->fetch(); $homeBranchId = $cookieLocation->locationId; $nearbyBranch1Id = $cookieLocation->nearbyLocation1; $nearbyBranch2Id = $cookieLocation->nearbyLocation2; } } } //Load the holding label for the user's home location. $userLocation = new Location(); $userLocation->whereAdd("locationId = '{$homeBranchId}'"); $userLocation->find(); if ($userLocation->N == 1) { $userLocation->fetch(); $homeBranch = $userLocation->holdingBranchLabel; } //Load nearby branch 1 $nearbyLocation1 = new Location(); $nearbyLocation1->whereAdd("locationId = '{$nearbyBranch1Id}'"); $nearbyLocation1->find(); if ($nearbyLocation1->N == 1) { $nearbyLocation1->fetch(); $nearbyBranch1 = $nearbyLocation1->holdingBranchLabel; } //Load nearby branch 2 $nearbyLocation2 = new Location(); $nearbyLocation2->whereAdd(); $nearbyLocation2->whereAdd("locationId = '{$nearbyBranch2Id}'"); $nearbyLocation2->find(); if ($nearbyLocation2->N == 1) { $nearbyLocation2->fetch(); $nearbyBranch2 = $nearbyLocation2->holdingBranchLabel; } //Get a list of items from Horizon $lookupTitleInfoUrl = $configArray['Catalog']['webServiceUrl'] . '/standard/lookupTitleInfo?clientID=' . $configArray['Catalog']['clientId'] . '&titleKey=' . $id . '&includeItemInfo=true&includeHoldCount=true'; $lookupTitleInfoResponse = $this->getWebServiceResponse($lookupTitleInfoUrl); $holdings = array(); if ($lookupTitleInfoResponse->titleInfo) { $i = 0; foreach ($lookupTitleInfoResponse->titleInfo->itemInfo as $itemInfo) { if (!isset($itemInfo->locationID)) { //Suppress anything without a location code continue; } $i++; $holding = array('id' => $id, 'number' => $i++, 'type' => 'holding', 'status' => isset($itemInfo->statusID) ? (string) $itemInfo->statusID : 'Unknown', 'statusfull' => isset($itemInfo->statusDescription) ? (string) $itemInfo->statusDescription : 'Unknown', 'availability' => isset($itemInfo->available) ? (string) $itemInfo->available == "true" : false, 'holdable' => true, 'reserve' => 'N', 'holdQueueLength' => (int) $lookupTitleInfoResponse->titleInfo->holdCount, 'dueDate' => isset($itemInfo->dueDate) ? (string) $itemInfo->dueDate : 'Unknown', 'locationCode' => (string) $itemInfo->locationID, 'location' => (string) $itemInfo->locationDescription, 'callnumber' => (string) $itemInfo->callNumber, 'isDownload' => false, 'barcode' => (string) $itemInfo->barcode, 'isLocalItem' => false, 'isLibraryItem' => true, 'locationLabel' => (string) $itemInfo->locationDescription, 'shelfLocation' => (string) $itemInfo->locationDescription); $holding['groupedStatus'] = mapValue('item_grouped_status', $holding['status']); $paddedNumber = str_pad($i, 3, '0', STR_PAD_LEFT); $sortString = $holding['location'] . '-' . $paddedNumber; //$sortString = $holding['location'] . $holding['callnumber']. $i; if (strlen($physicalBranch) > 0 && stripos($holding['location'], $physicalBranch) !== false) { //If the user is in a branch, those holdings come first. $holding['section'] = 'In this library'; $holding['sectionId'] = 1; $holding['isLocalItem'] = true; $sorted_array['1' . $sortString] = $holding; } else { if (strlen($homeBranch) > 0 && stripos($holding['location'], $homeBranch) !== false) { //Next come the user's home branch if the user is logged in or has the home_branch cookie set. $holding['section'] = 'Your library'; $holding['sectionId'] = 2; $holding['isLocalItem'] = true; $sorted_array['2' . $sortString] = $holding; } else { if (strlen($nearbyBranch1) > 0 && stripos($holding['location'], $nearbyBranch1) !== false) { //Next come nearby locations for the user $holding['section'] = 'Nearby Libraries'; $holding['sectionId'] = 3; $sorted_array['3' . $sortString] = $holding; } else { if (strlen($nearbyBranch2) > 0 && stripos($holding['location'], $nearbyBranch2) !== false) { //Next come nearby locations for the user $holding['section'] = 'Nearby Libraries'; $holding['sectionId'] = 4; $sorted_array['4' . $sortString] = $holding; //MDN 11/17 - taken out because all Horizon libraries are single institution (so far) /*} else if (strlen($libraryLocationLabels) > 0 && preg_match($libraryLocationLabels, $holding['location'])){ //Next come any locations within the same system we are in. $holding['section'] = $library->displayName; $holding['sectionId'] = 5; $sorted_array['5' . $sortString] = $holding; */ } else { //Finally, all other holdings are shown sorted alphabetically. $holding['section'] = $library->displayName; $holding['sectionId'] = 5; $sorted_array['5' . $sortString] = $holding; } } } } $holdings[] = $holding; } } return $holdings; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Location::find($id)->delete(); return Redirect::to('locations')->with('success', 'Location Deleted Successfully'); }
public function placeHoldViaSIP($recordId, $patronId, $comment, $type) { global $configArray; global $user; //Place the hold via SIP 2 $mysip = new sip2(); $mysip->hostname = $configArray['SIP2']['host']; $mysip->port = $configArray['SIP2']['port']; $hold_result = array(); $hold_result['result'] = false; if ($mysip->connect()) { //send selfcheck status message $in = $mysip->msgSCStatus(); $msg_result = $mysip->get_message($in); // Make sure the response is 98 as expected if (preg_match("/^98/", $msg_result)) { $result = $mysip->parseACSStatusResponse($msg_result); // Use result to populate SIP2 setings $mysip->AO = $result['variable']['AO'][0]; /* set AO to value returned */ $mysip->AN = $result['variable']['AN'][0]; /* set AN to value returned */ $mysip->patron = $user->cat_username; $mysip->patronpwd = $user->cat_password; if (isset($_REQUEST['campus'])) { $campus = trim($_REQUEST['campus']); } else { $campus = $user->homeLocationId; //Get the code for the location $locationLookup = new Location(); $locationLookup->locationId = $campus; $locationLookup->find(); if ($locationLookup->N > 0) { $locationLookup->fetch(); $campus = $locationLookup->code; } } //place the hold if ($type == 'cancel' || $type == 'recall') { $mode = '-'; } elseif ($type == 'update') { $mode = '*'; } else { $mode = '+'; } //expire the hold in 2 years by default $expirationTime = time() + 2 * 365 * 24 * 60 * 60; $in = $mysip->msgHold($mode, $expirationTime, '2', '', $recordId, '', $campus); $msg_result = $mysip->get_message($in); $hold_result['title'] = $this->getRecordTitle($recordId); $hold_result['id'] = $recordId; if (preg_match("/^16/", $msg_result)) { $result = $mysip->parseHoldResponse($msg_result); $hold_result['result'] = $result['fixed']['Ok'] == 1; $hold_result['message'] = $result['variable']['AF'][0]; //Get the hold position. if ($result['fixed']['Ok'] == 1) { $holds = $this->getMyHolds($user); //Find the correct hold (will be unavailable) foreach ($holds['holds']['unavailable'] as $key => $holdInfo) { if ($holdInfo['id'] == $recordId) { $hold_result['message'] .= " You are number <b>" . $holdInfo['position'] . "</b> in the queue."; break; } } } } } } return $hold_result; }
Route::get('{accessoryID}/view', ['as' => 'api.consumables.view', 'uses' => 'ConsumablesController@getDataView']); }); /*---Users API---*/ Route::group(['prefix' => 'users'], function () { Route::post('/', ['as' => 'api.users.store', 'uses' => 'UsersController@store']); Route::get('list/{status?}', ['as' => 'api.users.list', 'uses' => 'UsersController@getDatatable']); }); /*---Licenses API---*/ Route::group(['prefix' => 'licenses'], function () { Route::get('list', ['as' => 'api.licenses.list', 'uses' => 'LicensesController@getDatatable']); }); /*---Locations API---*/ Route::group(['prefix' => 'locations'], function () { Route::resource('/', 'LocationsController'); Route::get('{locationID}/check', function ($locationID) { $location = Location::find($locationID); return $location; }); }); /*---Improvements API---*/ Route::group(['prefix' => 'asset_maintenances'], function () { Route::get('list', ['as' => 'api.asset_maintenances.list', 'uses' => 'AssetMaintenancesController@getDatatable']); }); /*---Models API---*/ Route::group(['prefix' => 'models'], function () { Route::resource('/', 'ModelsController'); Route::get('list/{status?}', ['as' => 'api.models.list', 'uses' => 'ModelsController@getDatatable']); Route::get('{modelId}/check', function ($modelId) { $model = Model::find($modelId); return $model->show_mac_address; });
/** * Edits an existing location and returns the location Object. * @return [type] [description] */ public function destroyLocation($id) { $location = Location::find($id); $location->delete(); return 'happy days'; }
/** * Remove the specified resource from storage. * @access public * @param int $id * @return Redirect */ public function destroy($id) { try { Location::find($id)->delete(); $flashMessage = 'Deleted location.'; } catch (Exception $e) { $flashMessage = $e->getMessage(); } return Redirect::to('/admin/locations/')->with('flashMessage', $flashMessage); }
function getHoursAndLocations() { //Get a list of locations for the current library global $library; $tmpLocation = new Location(); $tmpLocation->libraryId = $library->libraryId; $tmpLocation->showInLocationsAndHoursList = 1; $tmpLocation->orderBy('displayName'); $libraryLocations = array(); $tmpLocation->find(); if ($tmpLocation->N == 0) { //Get all locations $tmpLocation = new Location(); $tmpLocation->showInLocationsAndHoursList = 1; $tmpLocation->orderBy('displayName'); $tmpLocation->find(); } while ($tmpLocation->fetch()) { $mapAddress = urlencode(preg_replace('/\\r\\n|\\r|\\n/', '+', $tmpLocation->address)); $clonedLocation = clone $tmpLocation; $hours = $clonedLocation->getHours(); foreach ($hours as $key => $hourObj) { if (!$hourObj->closed) { $hourString = $hourObj->open; list($hour, $minutes) = explode(':', $hourString); if ($hour < 12) { $hourObj->open .= ' AM'; } elseif ($hour == 12) { $hourObj->open = 'Noon'; } elseif ($hour == 24) { $hourObj->open = 'Midnight'; } else { $hour -= 12; $hourObj->open = "{$hour}:{$minutes} PM"; } $hourString = $hourObj->close; list($hour, $minutes) = explode(':', $hourString); if ($hour < 12) { $hourObj->close .= ' AM'; } elseif ($hour == 12) { $hourObj->close = 'Noon'; } elseif ($hour == 24) { $hourObj->close = 'Midnight'; } else { $hour -= 12; $hourObj->close = "{$hour}:{$minutes} PM"; } } $hours[$key] = $hourObj; } $libraryLocations[] = array('id' => $tmpLocation->locationId, 'name' => $tmpLocation->displayName, 'address' => preg_replace('/\\r\\n|\\r|\\n/', '<br/>', $tmpLocation->address), 'phone' => $tmpLocation->phone, 'map_image' => "http://maps.googleapis.com/maps/api/staticmap?center={$mapAddress}&zoom=15&size=200x200&sensor=false&markers=color:red%7C{$mapAddress}", 'map_link' => "http://maps.google.com/maps?f=q&hl=en&geocode=&q={$mapAddress}&ie=UTF8&z=15&iwloc=addr&om=1&t=m", 'hours' => $hours); } global $interface; $interface->assign('libraryLocations', $libraryLocations); return $interface->fetch('AJAX/libraryHoursAndLocations.tpl'); }
/** * Process SIP2 User Account * * @param array $info An array of user information * @param string $username The user's ILS username * @param string $password The user's ILS password * @param array $patronInfoResponse The user's ILS password * @return User * @access public * @author Bob Wicksall <*****@*****.**> */ private function processSIP2User($info, $username, $password, $patronInfoResponse) { global $timer; require_once ROOT_DIR . "/services/MyResearch/lib/User.php"; $user = new User(); $user->username = $info['variable']['AA'][0]; if ($user->find(true)) { $insert = false; } else { $insert = true; } // This could potentially be different depending on the ILS. Name could be Bob Wicksall or Wicksall, Bob. // This is currently assuming Wicksall, Bob if (strpos($info['variable']['AE'][0], ',') !== false) { $user->firstname = trim(substr($info['variable']['AE'][0], 1 + strripos($info['variable']['AE'][0], ','))); $user->lastname = trim(substr($info['variable']['AE'][0], 0, strripos($info['variable']['AE'][0], ','))); } else { $user->lastname = trim(substr($info['variable']['AE'][0], 1 + strripos($info['variable']['AE'][0], ' '))); $user->firstname = trim(substr($info['variable']['AE'][0], 0, strripos($info['variable']['AE'][0], ' '))); } // I'm inserting the sip username and password since the ILS is the source. // Should revisit this. $user->cat_username = $username; $user->cat_password = $password; $user->email = isset($patronInfoResponse['variable']['BE'][0]) ? $patronInfoResponse['variable']['BE'][0] : ''; $user->phone = isset($patronInfoResponse['variable']['BF'][0]) ? $patronInfoResponse['variable']['BF'][0] : ''; $user->major = 'null'; $user->college = 'null'; $user->patronType = $patronInfoResponse['variable']['PC'][0]; //Get home location //Check AO? if ((!isset($user->homeLocationId) || $user->homeLocationId == 0) && (isset($patronInfoResponse['variable']['AQ']) || isset($patronInfoResponse['variable']['AO']))) { $location = new Location(); if (isset($patronInfoResponse['variable']['AQ'])) { $location->code = $patronInfoResponse['variable']['AQ'][0]; } else { $location->code = $patronInfoResponse['variable']['AO'][0]; } $location->find(); if ($location->N > 0) { $location->fetch(); $user->homeLocationId = $location->locationId; } } if ($insert) { $user->created = date('Y-m-d'); $user->insert(); } else { $user->update(); } $timer->logTime("Processed SIP2 User"); return $user; }
/** * Delete employee location from DB * * @param $id * @return mixed */ public function deleteLocation($id) { $location = Location::find($id); if (count($location->employees()->get()->toArray())) { return Redirect::back()->with('danger_flash_message', 'You cannot delete a location that is in use.'); } $location->delete(); return Redirect::route('manageLocations')->with('flash_message', 'Location ' . $location->name . ' has been deleted'); }