Example #1
0
 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 = Sp4kAppsParentApp::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 = ["CONCAT(parent.f_name, ' ', parent.l_name)" => ['operator' => 'LIKE', 'value' => '%' . $q->name . '%', 'skipfieldquote' => true]];
             unset($q->name);
         } else {
             foreach ($q as $key => $field) {
                 $filters[$key] = ['operator' => 'LIKE', 'value' => '%' . $field . '%', 'skipfieldquote' => false];
             }
         }
         $appState = new Joomla\Registry\Registry(['limit' => $limit, 'count' => $count, 'filters' => $filters]);
         $this->items = Sp4kAppsParentApp::getInstance($appState)->getItems();
     } else {
         $state = new Joomla\Registry\Registry($this->state->toObject());
         $this->items = Sp4kAppsParentApp::getInstance($state)->getItems();
     }
 }
Example #2
0
 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();
 }
Example #3
0
 protected function bind()
 {
     $stateProperties = $this->getState()->toArray();
     foreach (get_object_vars($this) as $index => $property) {
         //get the defined properties for this class.
         if (array_key_exists($index, $stateProperties)) {
             //if the state contains an index of the same name
             if (in_array($index, $this->_toJson) && !is_string($stateProperties[$index])) {
                 $stateProperties[$index] = json_encode($stateProperties[$index]);
             }
             $this->{$index} = $stateProperties[$index];
             //assign its value to this instance.
         }
     }
     $this->items = Sp4kAppsOrderLinesApp::getInstance(new Registry(['data' => $this->getState()->get('items', false), 'filters' => ['order_id' => $this->getState()->get('id')]]))->getItems();
     $this->parent = Sp4kAppsParentApp::getInstance(new Registry(['filters' => ['account_id' => $this->getState()->get('account_id'), 'primary' => 1], 'keys' => false]))->getItems()[0];
 }
Example #4
0
 private function buildUser()
 {
     $sp4k_user = Sp4kAppsParentApp::getInstance(new Registry(['filters' => ['juser_id' => JFactory::getUser()->id]]))->getItems()[0];
     $user = new stdClass();
     $user->customerRef = $sp4k_user->id;
     $user->title = $sp4k_user->title;
     $user->firstName = $sp4k_user->f_name;
     $user->surname = $sp4k_user->l_name;
     $user->postCode = $sp4k_user->address_postalcode = $this->_state->get('paymentinfo')->address_postalcode;
     $user->line1 = $sp4k_user->address_street1 = $this->_state->get('paymentinfo')->address_postalcode;
     $user->line2 = $sp4k_user->address_street2 = $this->_state->get('paymentinfo')->address_postalcode;
     $user->homePhoneNumber = $sp4k_user->phone_home;
     $user->mobilePhoneNumber = $sp4k_user->phone_mobile;
     $user->email = JFactory::getUser()->email;
     $user->accountHolderName = $this->_state->get('paymentinfo')->accountHolderName;
     $user->accountNumber = $this->_state->get('paymentinfo')->accountNumber;
     $user->bankSortCode = $this->_state->get('paymentinfo')->bankSortCode;
     $this->_state->set('user', $user);
 }
Example #5
0
 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, 'joins' => $this->state->get('joins', false)]);
         /** @var Sp4kAppsAccountApp $registrationApp */
         $app = Sp4kAppsAccountApp::getInstance($appState);
         $appCollection = $app->getCollection();
         $this->count = $appCollection->count;
         $this->items = $appCollection->items;
         foreach ($this->items as &$item) {
             $item->parents = Sp4kAppsParentApp::getInstance(new Registry(['filters' => ['account_id' => $item->id], 'keys' => false]))->getItems();
         }
     } else {
         $this->items = Sp4kAppsAccountApp::getInstance(new Joomla\Registry\Registry($this->state->toObject()))->getItems();
     }
 }
Example #6
0
 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();
     }
 }
Example #7
0
 public function execute()
 {
     $app = new Sp4kAppsParentApp(new Joomla\Registry\Registry($this->state->toObject()));
     $this->item = $app->getItem();
 }
Example #8
0
 private function createParent()
 {
     $this->parent = Sp4kAppsParentApp::getInstance(new Registry(['juser_id' => $this->juser->id, 'account_id' => $this->account->id, 'f_name' => $this->state->get('f_name'), 'l_name' => $this->state->get('l_name'), 'primary' => 1, 'sms' => $this->state->get('sms'), 'state' => 1]))->getItem()->update();
     //todo test result and set error on fail.
 }
Example #9
0
 private function setParent()
 {
     $this->parent = Sp4kAppsParentApp::getInstance(new Registry(['filters' => ['juser_id' => JFactory::getUser()->id]]))->getItems()[0];
 }