protected function execute() { if ($this->state->get('paging', false)) { $limit = $this->state->get('limit'); $filters = $this->state->get('filters'); $count = $this->state->get('count', false); $appState = new Joomla\Registry\Registry(['limit' => $limit, 'count' => $count, 'filters' => $filters]); /** @var Sp4kAppsSubscriptionApp $registrationApp */ $app = Sp4kAppsChildApp::getInstance($appState); $appCollection = $app->getCollection(); $this->count = $appCollection->count; $this->items = $appCollection->items; foreach ($this->items as &$item) { $item->children = Sp4kAppsChildApp::getInstance(new Joomla\Registry\Registry(['filters' => ['account_id' => $item->account_id]]))->getItems(); } } elseif ($q = $this->state->get('q', false)) { $limit = $this->state->get('limit', [0, 5], 'ARRAY'); $count = $this->state->get('count', false); if (isset($q->name)) { $filters = ["child.name" => ['operator' => 'LIKE', 'value' => '%' . $q->name . '%', 'skipfieldquote' => true]]; } $appState = new Joomla\Registry\Registry(['limit' => $limit, 'count' => $count, 'filters' => $filters]); $this->items = Sp4kAppsChildApp::getInstance($appState)->getItems(); } else { $state = new Joomla\Registry\Registry($this->state->toObject()); $this->items = Sp4kAppsChildApp::getInstance($state)->getItems(); } }
private function createChildren() { foreach ($this->state->get('child') as $child) { $child->dob = strtotime($child->dob); $child->account_id = $this->account->id; $childItem = Sp4kAppsChildApp::getInstance(new Registry($child))->getItem()->update(); } //todo test result and set error on fail. }
private function setAttendeeOptions() { $parentFilters = new stdClass(); $parentFilters->juser_id = JFactory::getUser()->id; $parentAppItems = Sp4kAppsParentApp::getInstance(new Registry(['filters' => $parentFilters]))->getItems(); $parent = array_pop($parentAppItems); $childFilters = new stdClass(); $childFilters->parent_id = $parent->id; $this->children = Sp4kAppsChildApp::getInstance(new Registry(['filters' => $childFilters]))->getItems(); }
private function setSublines() { $this->getState()->set('event.rrule', Sp4kAppsRruleApp::getInstance(new Registry(['id' => $this->event->rrule_id]))->getItem()); //iterate over children in the cart and set up values. foreach ($this->getState()->get('children') as $child_id) { $childItem = Sp4kAppsChildApp::getInstance(new Registry(['id' => $child_id]))->getItem(); $startDate = $this->getState()->get('startdates')[$child_id]; $daysinbilling = $this->getNumDates(strftime('%Y%m%dT115959Z', $startDate), strftime('%Y%m%dT115959Z', strtotime('+30 days', $startDate))); $this->sublines[$child_id]['startdate'] = $startDate; $this->sublines[$child_id]['description'] = $childItem->name . ' starting ' . strftime('%d/%m/%Y', $startDate); $this->total += $this->sublines[$child_id]['total'] = $daysinbilling * json_decode($this->product->config)->pricing->unit_price; } }
protected function execute() { if ($this->state->get('paging', false)) { $limit = $this->state->get('limit'); $filters = $this->state->get('filters'); $count = $this->state->get('count', false); $appState = new Joomla\Registry\Registry(['limit' => $limit, 'count' => $count, 'filters' => $filters]); /** @var Sp4kAppsSubscriptionApp $registrationApp */ $app = Sp4kAppsSubscriptionApp::getInstance($appState); $appCollection = $app->getCollection(); $this->count = $appCollection->count; $this->items = $appCollection->items; foreach ($this->items as $item) { $item->child = Sp4kAppsChildApp::getInstance(new Registry(['id' => $item->child_id]))->getItem(); $item->product = Sp4kAppsProductApp::getInstance(new Registry(['id' => $item->product_id, 'plugins' => false]))->getItem(); } } else { $this->items = Sp4kAppsSubscriptionApp::getInstance(new Joomla\Registry\Registry($this->state->toObject()))->getItems(); } }
public function update() { if (!isset($this->item->account_id)) { $account = Sp4kAppsAccountApp::getInstance(new Registry(['created' => time()]))->getItem()->update(); $this->item->account_id = $account->id; } if ($this->item->juser_id == null || $this->item->juser_id == 0) { if (isset($this->item->email) && $this->item->email != '' && trim($this->item->f_name . ' ' . $this->item->l_name) != '' && !JUserHelper::getUserId($this->item->email)) { $this->item->juser_id = $this->addJoomlaUser(strtolower($this->item->email), $this->item->f_name . ' ' . $this->item->l_name, strtolower($this->item->email), JUserHelper::genRandomPassword()); } else { $this->item->juser_id = 0; } } if ($this->state->get('children', false)) { foreach ($this->state->get('children') as $child) { $childAppItem = Sp4kAppsChildApp::getInstance(new Registry($child))->getItem(); $childAppItem->account_id = $account->id; $childAppItem->update(); } } $this->item->update(); }
public function execute() { $app = new Sp4kAppsAccountApp(new Registry($this->state->toObject())); $this->item = $app->getItem(); $this->id = $this->item->id; $this->created = $this->item->created; $accountFilter = ['filters' => ['account_id' => $this->id]]; if ($this->item->id != null) { $this->item->parents = Sp4kAppsParentApp::getInstance(new Registry($accountFilter))->getItems(); foreach ($this->item->parents as &$parent) { $juser = JFactory::getuser($parent->juser_id); $parent->name = $juser->name; $parent->email = $juser->email; } $this->item->children = Sp4kAppsChildApp::getInstance(new Registry($accountFilter))->getItems(); foreach ($this->item->children as $child) { $this->item->registrations = $this->item->registrations + Sp4kAppsRegistrationApp::getInstance(new Registry(['filters' => ['child_id' => $child->id]]))->getItems(); } $this->item->subscriptions = Sp4kAppsSubscriptionApp::getInstance(new Registry($accountFilter))->getItems(); $this->item->orders = Sp4kAppsOrderApp::getInstance(new Registry($accountFilter))->getItems(); } }
private function setAttendee() { if ($child_id = $this->_state->get('child_id', $this->_state->get('attendee', false))) { $this->attendee = Sp4kAppsChildApp::getInstance(new Registry(['id' => $child_id]))->getItem(); } }
public function execute() { $app = new Sp4kAppsChildApp(new Joomla\Registry\Registry($this->state->toObject())); $this->item = $app->getItem(); }
public function execute() { $app = Sp4kAppsChildApp::getInstance(new Registry(['id' => $this->item->data['child_id']])); $child = $app->getItem(); $this->item->child = $child; }
public function load() { parent::load(); $this->child = Sp4kAppsChildApp::getInstance(new Registry(['id' => (int) $this->getState()->get('child_id')]))->getItem(); $this->product = Sp4kAppsProductApp::getInstance(new Registry(['id' => (int) $this->getState()->get('product_id')]))->getItem(); }