public function getTagsCollection()
 {
     $allTags = new ArrayList();
     $max = 0;
     $member = Member::currentUser();
     // Find if we need to filter tags by current discussion page
     $controller = Controller::curr();
     if (method_exists($controller, "data")) {
         $page = $controller->data();
     } else {
         $page = null;
     }
     if ($page != null && $page instanceof DiscussionPage) {
         $discussions = $page->Discussions();
     } else {
         $discussions = Discussion::get();
     }
     if ($discussions) {
         foreach ($discussions as $discussion) {
             if ($discussion->canView($member)) {
                 $theseTags = preg_split(" *, *", trim($discussion->Tags));
                 foreach ($theseTags as $tag) {
                     if ($tag) {
                         if ($allTags->find("Tag", $tag)) {
                             $allTags->find("Tag", $tag)->Count++;
                         } else {
                             $allTags->push(new ArrayData(array("Tag" => $tag, "Count" => 1, "Link" => Controller::join_links($discussion->Parent()->Link("tag"), Convert::raw2url($tag)))));
                         }
                         $tag_count = $allTags->find("Tag", $tag)->Count;
                         $max = $tag_count > $max ? $tag_count : $max;
                     }
                 }
             }
         }
         if ($allTags->exists()) {
             // First sort our tags
             $allTags->sort($this->SortParam, $this->SortOrder);
             // Now if a limit has been set, limit the list
             if ($this->Limit) {
                 $allTags = $allTags->limit($this->Limit);
             }
         }
         return $allTags;
     }
     return;
 }
 /**
  * Find an existing item and update its quantity
  *
  * @param Item
  * @param Quantity
  */
 public function update($item_key, $quantity)
 {
     $item = $this->items->find("Key", $item_key);
     if ($item) {
         $item->Quantity = $quantity;
         $this->extend("onBeforeUpdate", $item);
         $this->save();
     }
     return false;
 }
 /**
  * Find an existing item and update its quantity
  *
  * @param Item
  * @param Quantity
  */
 public function update($item_key, $quantity)
 {
     $item = $this->items->find("Key", $item_key);
     if ($item) {
         // If we need to track stock, do it now
         if ($this->config()->check_stock_levels) {
             $item->checkStockLevel($quantity);
         }
         $item->Quantity = floor($quantity);
         $this->extend("onBeforeUpdate", $item);
         $this->save();
     }
     return false;
 }
예제 #4
0
 public function testFind()
 {
     $list = new ArrayList(array(array('Name' => 'Steve'), (object) array('Name' => 'Bob'), array('Name' => 'John')));
     $this->assertEquals($list->find('Name', 'Bob'), (object) array('Name' => 'Bob'));
 }
 /**
  * Process the form that is submitted through the site
  * 
  * @param array $data
  * @param Form $form
  *
  * @return Redirection
  */
 public function process($data, $form)
 {
     Session::set("FormInfo.{$form->FormName()}.data", $data);
     Session::clear("FormInfo.{$form->FormName()}.errors");
     foreach ($this->Fields() as $field) {
         $messages[$field->Name] = $field->getErrorMessage()->HTML();
         $formField = $field->getFormField();
         if ($field->Required && $field->CustomRules()->Count() == 0) {
             if (isset($data[$field->Name])) {
                 $formField->setValue($data[$field->Name]);
             }
             if (!isset($data[$field->Name]) || !$data[$field->Name] || !$formField->validate($form->getValidator())) {
                 $form->addErrorMessage($field->Name, $field->getErrorMessage(), 'bad');
             }
         }
     }
     if (Session::get("FormInfo.{$form->FormName()}.errors")) {
         Controller::curr()->redirectBack();
         return;
     }
     $submittedForm = Object::create('SubmittedForm');
     $submittedForm->SubmittedByID = ($id = Member::currentUserID()) ? $id : 0;
     $submittedForm->ParentID = $this->ID;
     // if saving is not disabled save now to generate the ID
     if (!$this->DisableSaveSubmissions) {
         $submittedForm->write();
     }
     $values = array();
     $attachments = array();
     $submittedFields = new ArrayList();
     foreach ($this->Fields() as $field) {
         if (!$field->showInReports()) {
             continue;
         }
         $submittedField = $field->getSubmittedFormField();
         $submittedField->ParentID = $submittedForm->ID;
         $submittedField->Name = $field->Name;
         $submittedField->Title = $field->getField('Title');
         // save the value from the data
         if ($field->hasMethod('getValueFromData')) {
             $submittedField->Value = $field->getValueFromData($data);
         } else {
             if (isset($data[$field->Name])) {
                 $submittedField->Value = $data[$field->Name];
             }
         }
         if (!empty($data[$field->Name])) {
             if (in_array("EditableFileField", $field->getClassAncestry())) {
                 if (isset($_FILES[$field->Name])) {
                     $foldername = $field->getFormField()->getFolderName();
                     // create the file from post data
                     $upload = new Upload();
                     $file = new File();
                     $file->ShowInSearch = 0;
                     try {
                         $upload->loadIntoFile($_FILES[$field->Name], $file, $foldername);
                     } catch (ValidationException $e) {
                         $validationResult = $e->getResult();
                         $form->addErrorMessage($field->Name, $validationResult->message(), 'bad');
                         Controller::curr()->redirectBack();
                         return;
                     }
                     // write file to form field
                     $submittedField->UploadedFileID = $file->ID;
                     // attach a file only if lower than 1MB
                     if ($file->getAbsoluteSize() < 1024 * 1024 * 1) {
                         $attachments[] = $file;
                     }
                 }
             }
         }
         $submittedField->extend('onPopulationFromField', $field);
         if (!$this->DisableSaveSubmissions) {
             $submittedField->write();
         }
         $submittedFields->push($submittedField);
     }
     $emailData = array("Sender" => Member::currentUser(), "Fields" => $submittedFields);
     $this->extend('updateEmailData', $emailData, $attachments);
     // email users on submit.
     if ($recipients = $this->FilteredEmailRecipients($data, $form)) {
         $email = new UserDefinedForm_SubmittedFormEmail($submittedFields);
         $mergeFields = $this->getMergeFieldsMap($emailData['Fields']);
         if ($attachments) {
             foreach ($attachments as $file) {
                 if ($file->ID != 0) {
                     $email->attachFile($file->Filename, $file->Filename, HTTP::get_mime_type($file->Filename));
                 }
             }
         }
         foreach ($recipients as $recipient) {
             $parsedBody = SSViewer::execute_string($recipient->getEmailBodyContent(), $mergeFields);
             if (!$recipient->SendPlain && $recipient->emailTemplateExists()) {
                 $email->setTemplate($recipient->EmailTemplate);
             }
             $email->populateTemplate($recipient);
             $email->populateTemplate($emailData);
             $email->setFrom($recipient->EmailFrom);
             $email->setBody($parsedBody);
             $email->setTo($recipient->EmailAddress);
             $email->setSubject($recipient->EmailSubject);
             if ($recipient->EmailReplyTo) {
                 $email->setReplyTo($recipient->EmailReplyTo);
             }
             // check to see if they are a dynamic reply to. eg based on a email field a user selected
             if ($recipient->SendEmailFromField()) {
                 $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailFromField()->Name);
                 if ($submittedFormField && is_string($submittedFormField->Value)) {
                     $email->setReplyTo($submittedFormField->Value);
                 }
             }
             // check to see if they are a dynamic reciever eg based on a dropdown field a user selected
             if ($recipient->SendEmailToField()) {
                 $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailToField()->Name);
                 if ($submittedFormField && is_string($submittedFormField->Value)) {
                     $email->setTo($submittedFormField->Value);
                 }
             }
             // check to see if there is a dynamic subject
             if ($recipient->SendEmailSubjectField()) {
                 $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailSubjectField()->Name);
                 if ($submittedFormField && trim($submittedFormField->Value)) {
                     $email->setSubject($submittedFormField->Value);
                 }
             }
             $this->extend('updateEmail', $email, $recipient, $emailData);
             if ($recipient->SendPlain) {
                 $body = strip_tags($recipient->getEmailBodyContent()) . "\n";
                 if (isset($emailData['Fields']) && !$recipient->HideFormData) {
                     foreach ($emailData['Fields'] as $Field) {
                         $body .= $Field->Title . ': ' . $Field->Value . " \n";
                     }
                 }
                 $email->setBody($body);
                 $email->sendPlain();
             } else {
                 $email->send();
             }
         }
     }
     $submittedForm->extend('updateAfterProcess');
     Session::clear("FormInfo.{$form->FormName()}.errors");
     Session::clear("FormInfo.{$form->FormName()}.data");
     $referrer = isset($data['Referrer']) ? '?referrer=' . urlencode($data['Referrer']) : "";
     // set a session variable from the security ID to stop people accessing
     // the finished method directly.
     if (!$this->DisableAuthenicatedFinishAction) {
         if (isset($data['SecurityID'])) {
             Session::set('FormProcessed', $data['SecurityID']);
         } else {
             // if the form has had tokens disabled we still need to set FormProcessed
             // to allow us to get through the finshed method
             if (!$this->Form()->getSecurityToken()->isEnabled()) {
                 $randNum = rand(1, 1000);
                 $randHash = md5($randNum);
                 Session::set('FormProcessed', $randHash);
                 Session::set('FormProcessedNum', $randNum);
             }
         }
     }
     if (!$this->DisableSaveSubmissions) {
         Session::set('userformssubmission' . $this->ID, $submittedForm->ID);
     }
     return $this->redirect($this->Link('finished') . $referrer . $this->config()->finished_anchor);
 }
예제 #6
0
 /**
  * Returns the sum of tax amounts grouped by tax rates for the products
  * of the order.
  *
  * @param boolean $includeChargesForProducts Indicates wether to include charges and
  *                                           discounts for products
  * @param boolean $includeChargesForTotal    Indicates wether to include charges and
  *                                           discounts for the shopping cart total
  * 
  * @return ArrayList
  */
 public function getTaxRatesWithoutFees($includeChargesForProducts = false, $includeChargesForTotal = false)
 {
     if ($includeChargesForTotal === 'false') {
         $includeChargesForTotal = false;
     }
     if ($includeChargesForProducts === 'false') {
         $includeChargesForProducts = false;
     }
     $taxes = new ArrayList();
     foreach ($this->SilvercartOrderPositions() as $orderPosition) {
         if (!$includeChargesForProducts && $orderPosition->isChargeOrDiscount && $orderPosition->chargeOrDiscountModificationImpact == 'productValue' || !$includeChargesForTotal && $orderPosition->isChargeOrDiscount && $orderPosition->chargeOrDiscountModificationImpact == 'totalValue') {
             continue;
         }
         $taxRate = $orderPosition->TaxRate;
         if ($taxRate == '') {
             $taxRate = 0;
         }
         if ($taxRate >= 0 && !$taxes->find('Rate', $taxRate)) {
             $taxes->push(new DataObject(array('Rate' => $taxRate, 'AmountRaw' => 0.0)));
         }
         $taxSection = $taxes->find('Rate', $taxRate);
         $taxSection->AmountRaw += $orderPosition->TaxTotal;
     }
     foreach ($taxes as $tax) {
         $taxObj = new Money();
         $taxObj->setAmount($tax->AmountRaw);
         $taxObj->setCurrency(SilvercartConfig::DefaultCurrency());
         $tax->Amount = $taxObj;
     }
     return $taxes;
 }
 public function ExportFullSchedule()
 {
     $sort = $this->getRequest()->getVar('sort') ? $this->getRequest()->getVar('sort') : 'day';
     $show_desc = $this->getRequest()->getVar('show_desc') ? $this->getRequest()->getVar('show_desc') : false;
     $base = Director::protocolAndHost();
     if (is_null($this->Summit())) {
         return $this->httpError(404, 'Sorry, summit not found');
     }
     $schedule = $this->Summit()->getSchedule();
     $events = new ArrayList();
     $sort_list = false;
     foreach ($schedule as $event) {
         switch ($sort) {
             case 'day':
                 $group_label = $event->getDayLabel();
                 break;
             case 'track':
                 if (!$event->isPresentation() || !$event->Category() || !$event->Category()->Title) {
                     continue 2;
                 }
                 $group_label = $event->Category()->Title;
                 $sort_list = true;
                 break;
             case 'event_type':
                 $group_label = $event->Type->Type;
                 $sort_list = true;
                 break;
         }
         if ($group_array = $events->find('Group', $group_label)) {
             $group_array->Events->push($event);
         } else {
             $group_array = new ArrayData(array('Group' => $group_label, 'Events' => new ArrayList()));
             $group_array->Events->push($event);
             $events->push($group_array);
         }
     }
     if ($sort_list) {
         $events->sort('Group');
     }
     $html_inner = $this->renderWith(array('SummitAppMySchedulePage_pdf'), array('Schedule' => $events, 'Summit' => $this->Summit(), 'ShowDescription' => $show_desc, 'Heading' => 'Full Schedule by ' . $sort));
     $css = @file_get_contents($base . "/summit/css/summitapp-myschedule-pdf.css");
     //create pdf
     $file = FileUtils::convertToFileName('full-schedule') . '.pdf';
     $html_outer = sprintf("<html><head><style>%s</style></head><body><div class='container'>%s</div></body></html>", $css, $html_inner);
     try {
         $html2pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8', array(15, 5, 15, 5));
         $html2pdf->setTestIsImage(false);
         $html2pdf->WriteHTML($html_outer);
         //clean output buffer
         ob_end_clean();
         $html2pdf->Output($file, "D");
     } catch (HTML2PDF_exception $e) {
         $message = array('errno' => '', 'errstr' => $e->__toString(), 'errfile' => 'SummitAppSchedPage.php', 'errline' => '', 'errcontext' => '');
         SS_Log::log($message, SS_Log::ERR);
         $this->httpError(404, 'There was an error on PDF generation!');
     }
 }
 /**
  * Process the form that is submitted through the site
  * 
  * @param Array Data
  * @param Form Form 
  * @return Redirection
  */
 public function process($data, $form)
 {
     Session::set("FormInfo.{$form->FormName()}.data", $data);
     Session::clear("FormInfo.{$form->FormName()}.errors");
     foreach ($this->Fields() as $field) {
         $messages[$field->Name] = $field->getErrorMessage()->HTML();
         if ($field->Required && $field->CustomRules()->Count() == 0) {
             if (!isset($data[$field->Name]) || !$data[$field->Name] || !$field->getFormField()->validate($this->validator)) {
                 $form->addErrorMessage($field->Name, $field->getErrorMessage()->HTML(), 'bad');
             }
         }
     }
     if (Session::get("FormInfo.{$form->FormName()}.errors")) {
         Controller::curr()->redirectBack();
         return;
     }
     $submittedForm = Object::create('SubmittedForm');
     $submittedForm->SubmittedByID = ($id = Member::currentUserID()) ? $id : 0;
     $submittedForm->ParentID = $this->ID;
     // if saving is not disabled save now to generate the ID
     if (!$this->DisableSaveSubmissions) {
         $submittedForm->write();
     }
     $values = array();
     $attachments = array();
     $submittedFields = new ArrayList();
     foreach ($this->Fields() as $field) {
         if (!$field->showInReports()) {
             continue;
         }
         $submittedField = $field->getSubmittedFormField();
         $submittedField->ParentID = $submittedForm->ID;
         $submittedField->Name = $field->Name;
         $submittedField->Title = $field->getField('Title');
         // save the value from the data
         if ($field->hasMethod('getValueFromData')) {
             $submittedField->Value = $field->getValueFromData($data);
         } else {
             if (isset($data[$field->Name])) {
                 $submittedField->Value = $data[$field->Name];
             }
         }
         if (!empty($data[$field->Name])) {
             if (in_array("EditableFileField", $field->getClassAncestry())) {
                 if (isset($_FILES[$field->Name])) {
                     // create the file from post data
                     $upload = new Upload();
                     $file = new File();
                     $file->ShowInSearch = 0;
                     try {
                         $upload->loadIntoFile($_FILES[$field->Name], $file);
                     } catch (ValidationException $e) {
                         $validationResult = $e->getResult();
                         $form->addErrorMessage($field->Name, $validationResult->message(), 'bad');
                         Controller::curr()->redirectBack();
                         return;
                     }
                     // write file to form field
                     $submittedField->UploadedFileID = $file->ID;
                     // attach a file only if lower than 1MB
                     if ($file->getAbsoluteSize() < 1024 * 1024 * 1) {
                         $attachments[] = $file;
                     }
                 }
             }
         }
         if (!$this->DisableSaveSubmissions) {
             $submittedField->write();
         }
         $submittedFields->push($submittedField);
     }
     $emailData = array("Sender" => Member::currentUser(), "Fields" => $submittedFields);
     // email users on submit.
     if ($this->EmailRecipients()) {
         $email = new UserDefinedForm_SubmittedFormEmail($submittedFields);
         $email->populateTemplate($emailData);
         if ($attachments) {
             foreach ($attachments as $file) {
                 if ($file->ID != 0) {
                     $email->attachFile($file->Filename, $file->Filename, HTTP::get_mime_type($file->Filename));
                 }
             }
         }
         foreach ($this->EmailRecipients() as $recipient) {
             $email->populateTemplate($recipient);
             $email->populateTemplate($emailData);
             $email->setFrom($recipient->EmailFrom);
             $email->setBody($recipient->EmailBody);
             $email->setSubject($recipient->EmailSubject);
             $email->setTo($recipient->EmailAddress);
             // check to see if they are a dynamic sender. eg based on a email field a user selected
             if ($recipient->SendEmailFromField()) {
                 $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailFromField()->Name);
                 if ($submittedFormField) {
                     $email->setFrom($submittedFormField->Value);
                 }
             }
             // check to see if they are a dynamic reciever eg based on a dropdown field a user selected
             if ($recipient->SendEmailToField()) {
                 $submittedFormField = $submittedFields->find('Name', $recipient->SendEmailToField()->Name);
                 if ($submittedFormField) {
                     $email->setTo($submittedFormField->Value);
                 }
             }
             $this->extend('updateEmail', $email, $recipient, $emailData);
             if ($recipient->SendPlain) {
                 $body = strip_tags($recipient->EmailBody) . "\n ";
                 if (isset($emailData['Fields']) && !$recipient->HideFormData) {
                     foreach ($emailData['Fields'] as $Field) {
                         $body .= $Field->Title . ' - ' . $Field->Value . ' \\n';
                     }
                 }
                 $email->setBody($body);
                 $email->sendPlain();
             } else {
                 $email->send();
             }
         }
     }
     Session::clear("FormInfo.{$form->FormName()}.errors");
     Session::clear("FormInfo.{$form->FormName()}.data");
     $referrer = isset($data['Referrer']) ? '?referrer=' . urlencode($data['Referrer']) : "";
     return $this->redirect($this->Link() . 'finished' . $referrer);
 }
예제 #9
0
 /**
  * Return the subsites that the current user can access by given permission.
  * Sites will only be included if they have a Title.
  *
  * @param $permCode array|string Either a single permission code or an array of permission codes.
  * @param $includeMainSite If true, the main site will be included if appropriate.
  * @param $mainSiteTitle The label to give to the main site
  * @param $member
  * @return DataList of {@link Subsite} instances
  */
 public static function accessible_sites($permCode, $includeMainSite = true, $mainSiteTitle = "Main site", $member = null)
 {
     // Rationalise member arguments
     if (!$member) {
         $member = Member::currentUser();
     }
     if (!$member) {
         return new ArrayList();
     }
     if (!is_object($member)) {
         $member = DataObject::get_by_id('Member', $member);
     }
     // Rationalise permCode argument
     if (is_array($permCode)) {
         $SQL_codes = "'" . implode("', '", Convert::raw2sql($permCode)) . "'";
     } else {
         $SQL_codes = "'" . Convert::raw2sql($permCode) . "'";
     }
     // Cache handling
     $cacheKey = $SQL_codes . '-' . $member->ID . '-' . $includeMainSite . '-' . $mainSiteTitle;
     if (isset(self::$_cache_accessible_sites[$cacheKey])) {
         return self::$_cache_accessible_sites[$cacheKey];
     }
     $subsites = DataList::create('Subsite')->where("\"Subsite\".\"Title\" != ''")->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = {$member->ID}")->innerJoin('Permission', "\"Group\".\"ID\"=\"Permission\".\"GroupID\" AND \"Permission\".\"Code\" IN ({$SQL_codes}, 'CMS_ACCESS_LeftAndMain', 'ADMIN')");
     if (!$subsites) {
         $subsites = new ArrayList();
     }
     $rolesSubsites = DataList::create('Subsite')->where("\"Subsite\".\"Title\" != ''")->leftJoin('Group_Subsites', "\"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"")->innerJoin('Group', "\"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\" OR \"Group\".\"AccessAllSubsites\" = 1")->innerJoin('Group_Members', "\"Group_Members\".\"GroupID\"=\"Group\".\"ID\" AND \"Group_Members\".\"MemberID\" = {$member->ID}")->innerJoin('Group_Roles', "\"Group_Roles\".\"GroupID\"=\"Group\".\"ID\"")->innerJoin('PermissionRole', "\"Group_Roles\".\"PermissionRoleID\"=\"PermissionRole\".\"ID\"")->innerJoin('PermissionRoleCode', "\"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\" AND \"PermissionRoleCode\".\"Code\" IN ({$SQL_codes}, 'CMS_ACCESS_LeftAndMain', 'ADMIN')");
     if (!$subsites && $rolesSubsites) {
         return $rolesSubsites;
     }
     $subsites = new ArrayList($subsites->toArray());
     if ($rolesSubsites) {
         foreach ($rolesSubsites as $subsite) {
             if (!$subsites->find('ID', $subsite->ID)) {
                 $subsites->push($subsite);
             }
         }
     }
     if ($includeMainSite) {
         if (!is_array($permCode)) {
             $permCode = array($permCode);
         }
         if (self::hasMainSitePermission($member, $permCode)) {
             $subsites = $subsites->toArray();
             $mainSite = new Subsite();
             $mainSite->Title = $mainSiteTitle;
             array_unshift($subsites, $mainSite);
             $subsites = ArrayList::create($subsites);
         }
     }
     self::$_cache_accessible_sites[$cacheKey] = $subsites;
     return $subsites;
 }
 /**
  * Returns tax amounts included in the shoppingcart separated by tax rates
  * without fee taxes.
  *
  * @param array $excludeModules              An array of registered modules that shall not
  *                                           be taken into account.
  * @param array $excludeShoppingCartPosition Positions that shall not be counted
  *
  * @return ArrayList
  */
 public function getTaxRatesWithoutFeesAndCharges($excludeModules = array(), $excludeShoppingCartPosition = false)
 {
     $positions = $this->SilvercartShoppingCartPositions();
     $taxes = new ArrayList();
     $registeredModules = $this->callMethodOnRegisteredModules('ShoppingCartPositions', array(SilvercartCustomer::currentUser()->getCart(), SilvercartCustomer::currentUser(), true), $excludeModules, $excludeShoppingCartPosition);
     // products
     foreach ($positions as $position) {
         $taxRate = $position->SilvercartProduct()->getTaxRate();
         $originalTaxRate = $position->SilvercartProduct()->getTaxRate(true);
         if (!$taxes->find('Rate', $taxRate)) {
             $taxes->push(new DataObject(array('Rate' => $taxRate, 'OriginalRate' => $originalTaxRate, 'AmountRaw' => (double) 0.0)));
         }
         $taxSection = $taxes->find('Rate', $taxRate);
         $taxSection->AmountRaw += $position->getTaxAmount();
     }
     // Registered Modules
     foreach ($registeredModules as $moduleName => $moduleOutput) {
         foreach ($moduleOutput as $modulePosition) {
             $taxRate = $modulePosition->TaxRate;
             if (!$taxes->find('Rate', $taxRate)) {
                 $taxes->push(new DataObject(array('Rate' => $taxRate, 'OriginalRate' => $taxRate, 'AmountRaw' => (double) 0.0)));
             }
             $taxSection = $taxes->find('Rate', $taxRate);
             $taxAmount = $modulePosition->TaxAmount;
             $taxSection->AmountRaw = round($taxSection->AmountRaw + $taxAmount, 4);
         }
     }
     foreach ($taxes as $tax) {
         $taxObj = new Money();
         $taxObj->setAmount($tax->AmountRaw);
         $taxObj->setCurrency(SilvercartConfig::DefaultCurrency());
         $tax->Amount = $taxObj;
     }
     return $taxes;
 }
 /**
  * @param string $id
  * @return YepnopeTestObject|null
  */
 public function get_test($id)
 {
     return $this->yepnopeTests->find('id', $id);
 }
예제 #12
0
 /**
  * Returns a customers purchased products
  * 
  * @return ArrayList
  */
 public function getPurchasedProducts()
 {
     $orders = $this->owner->SilvercartOrder();
     $purchasedProducts = new ArrayList();
     foreach ($orders as $order) {
         $positions = $order->SilvercartOrderPositions();
         foreach ($positions as $position) {
             if (!$purchasedProducts->find('ID', $position->SilvercartProductID)) {
                 $purchasedProducts->push($position->SilvercartProduct());
             }
         }
     }
     return $purchasedProducts;
 }