/** * * @param unknown $user * @return ZfJoacubUsersOnline\Entity\Register */ protected function getOrRegister($user) { if (isset($this->userRegister[$user->getId()])) { return $this->userRegister[$user->getId()]; } $em = $this->sl->get('zf_joacub_users_online_doctrine_em'); $em instanceof EntityManager; $repo = $em->getRepository('ZfJoacubUsersOnline\\Entity\\Register'); $registerEntity = $repo->findOneBy(array('user' => $user)); if (!$registerEntity) { $registerEntity = new Register(); $registerEntity->setUser($user); $auth = $this->sl->get('zfcuser_auth_service'); if ($auth->hasIdentity()) { if ($auth->getIdentity()->getId() == $user->getId()) { $registerEntity->setLastConnect(new \DateTime('now')); } else { $registerEntity->setLastConnect($user->getCreated()); } } $registerEntity->setLastConnect($user->getCreated()); $em->persist($registerEntity); $em->flush($registerEntity); } $this->userRegister[$user->getId()] = $registerEntity; return $registerEntity; }
/** * Constructs a new placeholder class and use the object to fill * the placeholder with. * * @param unknown $object */ public function __construct($object, $begin = "<<", $end = ">>") { $replace = array(); if ($object instanceof Part) { $replace = array('id' => $object->getId(), 'barcodeId' => $object->getId() * 10 + 1, 'name' => $object->getName(), 'internalNumber' => $object->getInternalPartNumber(), 'description' => $object->getDescription(), 'categoryFull' => $object->getCategory()->getCategoryPath(), 'categoryLast' => $object->getCategory()->getName(), 'footprintName' => $object->getFootprint() === null ? '' : $object->getFootprint()->getName(), 'storageLocationName' => $object->getStorageLocation() === null ? '' : $object->getStorageLocation()->getName()); } else { if ($object instanceof StorageLocation) { $replace = array('id' => $object->getId(), 'barcodeId' => $object->getId() * 10 + 2, 'name' => $object->getName()); } } $this->beginToken = $begin; $this->endToken = $end; $this->replacements = $replace; }
/** * Exports the delivery address */ protected function exportDeliveryAddress() { if ($this->ShippingAddress === null) { return; } if ($this->PLENTY_customerID === null) { return; } $city = trim($this->ShippingAddress->getCity()); $street_arr = PlentymarketsUtils::extractStreetAndHouseNo($this->ShippingAddress->getStreet()); if (isset($street_arr['street']) && strlen($street_arr['street']) > 0) { $streetName = $street_arr['street']; } else { $streetName = trim($this->ShippingAddress->getStreet()); } if (isset($street_arr['houseNo']) && strlen($street_arr['houseNo']) > 0) { $streetHouseNumber = $street_arr['houseNo']; } else { $streetHouseNumber = ''; } $zip = trim($this->ShippingAddress->getZipCode()); if (empty($city)) { $city = PlentymarketsConfig::getInstance()->get('CustomerDefaultCity'); } if (!isset($streetHouseNumber) || $streetHouseNumber == '') { $streetHouseNumber = PlentymarketsConfig::getInstance()->get('CustomerDefaultHouseNumber'); } if (!isset($streetName) || $streetName == '') { $streetName = PlentymarketsConfig::getInstance()->get('CustomerDefaultStreet'); } if ($zip == '') { $zip = PlentymarketsConfig::getInstance()->get('CustomerDefaultZipcode'); } $Request_SetCustomerDeliveryAddresses = new PlentySoapRequest_SetCustomerDeliveryAddresses(); $Request_SetCustomerDeliveryAddresses->DeliveryAddresses = array(); $Object_SetCustomerDeliveryAddressesCustomer = new PlentySoapRequest_ObjectSetCustomerDeliveryAddresses(); $Object_SetCustomerDeliveryAddressesCustomer->AdditionalName = null; // string $Object_SetCustomerDeliveryAddressesCustomer->City = $city; $Object_SetCustomerDeliveryAddressesCustomer->Company = $this->ShippingAddress->getCompany(); $Object_SetCustomerDeliveryAddressesCustomer->CountryID = $this->getDeliveryCountryID(); // int $Object_SetCustomerDeliveryAddressesCustomer->CustomerID = $this->PLENTY_customerID; // int $Object_SetCustomerDeliveryAddressesCustomer->ExternalDeliveryAddressID = PlentymarketsUtils::getExternalCustomerID($this->ShippingAddress->getId()); // string $Object_SetCustomerDeliveryAddressesCustomer->FirstName = $this->ShippingAddress->getFirstName(); $Object_SetCustomerDeliveryAddressesCustomer->FormOfAddress = $this->getDeliveryFormOfAddress(); // int $Object_SetCustomerDeliveryAddressesCustomer->HouseNumber = $streetHouseNumber; $Object_SetCustomerDeliveryAddressesCustomer->Street = $streetName; $Object_SetCustomerDeliveryAddressesCustomer->Surname = $this->ShippingAddress->getLastName(); $Object_SetCustomerDeliveryAddressesCustomer->ZIP = $zip; $Request_SetCustomerDeliveryAddresses->DeliveryAddresses[] = $Object_SetCustomerDeliveryAddressesCustomer; $Response_SetCustomerDeliveryAddresses = PlentymarketsSoapClient::getInstance()->SetCustomerDeliveryAddresses($Request_SetCustomerDeliveryAddresses); if (!$Response_SetCustomerDeliveryAddresses->Success) { throw new PlentymarketsExportEntityException('The delivery address of the customer with the number »' . $this->getCustomerNumber() . '« could not be exported', 2120); } $this->PLENTY_addressDispatchID = (int) $Response_SetCustomerDeliveryAddresses->ResponseMessages->item[0]->SuccessMessages->item[0]->Value; }
/** * Get product collection for only one product * @param unknown $product * @param int $store_id */ public function getProductCollectionByProduct($product, $store_id) { $collection = $this->getProductCollectionByStoreId($store_id); $collection->addAttributeToFilter('entity_id', array('in' => array($product->getId()))); return $collection; }
/** * Returns the object ID from the object * * @param unknown $object */ protected function getObjectId($object) { return $object->getId(); }
/** * 返回当前新增ID */ public function getId() { return $this->_db->getId(); }
/** * * @param unknown $devis * @param unknown $town * @param unknown $day * @param unknown $address * @param unknown $startTime * @param unknown $message * @return boolean */ public function create($devis, $town, $day, $address, $startTime, $duration, $message) { $client = $this->getCurrentUser(); $town = $this->em->getRepository('MainCommonBundle:Geo\\Town')->findOneById($town); $address = $address; $status = $this->em->getRepository('MainCommonBundle:Status\\PrestationStatus')->findOneById(self::PRESTATION_ENCOURS); $devisPrice = $this->em->getRepository('MainCommonBundle:Photographers\\DevisPrices')->findOneBy(array('devis' => $devis->getId(), 'duration' => $duration)); $duration = $devisPrice->getDuration(); $price = $devisPrice->getPrice(); $start = str_replace('/', '-', $day) . ' ' . $startTime . ':00'; $startTime = new \DateTime($start); $commission = $this->serviceCommissionPrestation->generateCommission($devis); $prestation = new Prestation(); $prestation->setReference($this->reference->generateReference()); $prestation->setDevis($devis); $prestation->setRappel($devis->getPresentation()); $prestation->setClient($client); $prestation->setTown($town); $prestation->setPrice($price); $prestation->setAddress($address); $prestation->setStartTime($startTime); $prestation->setDuration($duration); $prestation->setStatus($status); $prestation->setCommission($commission); try { $this->em->persist($prestation); $this->CreateMessage($prestation, $client, $devis->getCompany()->getPhotographer(), 1, $message); $this->em->flush(); $this->mailer->prestationUpdateEmail($prestation); $this->notification->createPrestationNotification($prestation); return $prestation; } catch (\Exception $e) { $this->session->errorFlashMessage(); $this->logger->error($e->getMessage()); return false; } }
/** * (non-PHPdoc) * * @see \Core\Html\Bootstrap\Panel\Panel::build() * * @throws ControlException */ public function build() { if (empty($this->form)) { throw new ControlException('Editbox control needs a set FormDesigner or Form object.'); } // Editbox CSS class needed $this->panel->html->addCss('editbox'); // Create panel heading with title $heading = $this->panel->createHeading(); $title = $heading->createTitle(); $title->setTitle($this->caption); if (!empty($this->description)) { $title->setDescription($this->description, true); } $heading->addContent($title); // Create panel body if ($this->form instanceof FormDesigner) { $form_id = $this->form->html->getId(); $form_action = $this->form->html->getAttribute('action'); // Ajax form? $this->is_ajax = $this->form->getSendMode() == 'ajax' ? true : false; } else { $form_id = $this->form->getId(); $form_action = $this->form->getAttribute('action'); } // Build form here because it's possible that form id will be autogenerated // and we need this id in the next step. $body = $this->panel->createBody(); $body->addContent($this->form); // Footer with toolbar /* @var $toolbar \Core\Html\Bootstrap\Buttongroups\ButtonToolbar */ $toolbar = $this->factory->create('Bootstrap\\Buttongroups\\ButtonToolbar'); $create_action = function (Action $action, $with_link = false) { $text = $action->getText(); $icon = $action->getIcon(); if (!empty($icon)) { $text = $icon->build() . ' ' . $text; } if ($with_link) { $href = $action->getHref(); if (!empty($href)) { /* @var $a \Core\Html\Elements\A */ $a = $this->factory->create('Elements\\A'); $a->setHref($href); if ($action->getAjax()) { $a->addData('ajax'); } if ($action->getConfirm()) { $a->addData('confirm', $action->getConfirm()); } $a->setInner($text); $text = $a->build(); } } return $text; }; // Make sure that he buttons have the correct order ksort($this->actions); foreach ($this->actions as $type => $action) { switch ($type) { case 0: case 1: /* @var $group \Core\Html\Bootstrap\Buttongroups\ButtonGroup */ $group = $toolbar->createButtongroup(); $group->addCss('btn-group-sm'); switch ($type) { case 0: $button = $group->createButton(); $button->setFormId($form_id); $button->setFormAction($form_action); $button->isSuccess(); if ($this->is_ajax) { $button->addData('ajax'); } else { $button->setType('submit'); } break; case 1: $group->addCss('pull-right'); /* @var $button \Core\Html\Controls\UiButton */ $button = $group->createButton('Controls\\UiButton'); $button->setHref($action->getHref()); $button->addCss('btn-danger'); if ($this->is_ajax) { $button->addData('ajax'); } break; } $button->setInner($create_action($this->actions[$type])); break; case 2: default: /* @var $group \Core\Html\Bootstrap\Buttongroups\ButtonGroup */ $group = $toolbar->createButtongroup(); $group->addCss('btn-group-sm pull-right dropup'); /* @var $context_menu \Core\Html\Form\Button */ $context_menu = $this->factory->create('Bootstrap\\Button\\Button'); $context_menu->addCss('dropdown-toggle'); $context_menu->addAria(['haspopup' => "true", 'expanded' => "false"]); $context_menu->addData('toggle', 'dropdown'); // Do we have a text to show on actions button? if (!empty($this->context_text)) { $context_menu->addInner($this->context_text . ' '); } $context_menu->addInner('<span class="caret"></span>'); $group->setInner($context_menu->build()); // Create the actions dropdown menu $dropdown = '<ul class="dropdown-menu">'; foreach ($this->actions[$type] as $action) { $dropdown .= '<li>' . $create_action($action, true) . '</li>'; } $dropdown .= '</ul>'; $group->addInner($dropdown); break; } } $footer = $this->panel->createFooter(); $footer->addContent($toolbar); return $this->panel->build(); }
/** * Get product price * @param unknown $_product * @param unknown $storeId * @return decimal */ public function getProductPrice($_product, $storeId) { $_coreHelper = Mage::helper('core'); $_weeeHelper = Mage::helper('weee'); $_taxHelper = Mage::helper('tax'); $_storeId = $_product->getStoreId(); $_id = $_product->getId(); $_weeeSeparator = ''; $_simplePricesTax = $_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices(); $_minimalPriceValue = $_product->getMinimalPrice(); $_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax); $returnPrice = $_product->getFinalPrice(); if ($_product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) { return $_product->getMinimalPrice(); } if (!$_product->isGrouped()) { $_weeeTaxAmount = $_weeeHelper->getAmountForDisplay($_product); if ($_weeeHelper->typeOfDisplay($_product, array(Mage_Weee_Model_Tax::DISPLAY_INCL_DESCR, Mage_Weee_Model_Tax::DISPLAY_EXCL_DESCR_INCL, 4))) { $_weeeTaxAmount = $_weeeHelper->getAmount($_product); $_weeeTaxAttributes = $_weeeHelper->getProductWeeeAttributesForDisplay($_product); } $_weeeTaxAmountInclTaxes = $_weeeTaxAmount; if ($_weeeHelper->isTaxable() && !$_taxHelper->priceIncludesTax($_storeId)) { $_attributes = $_weeeHelper->getProductWeeeAttributesForRenderer($_product, null, null, null, true); $_weeeTaxAmountInclTaxes = $_weeeHelper->getAmountInclTaxes($_attributes); } $_price = $_taxHelper->getPrice($_product, $_product->getPrice()); $_regularPrice = $_taxHelper->getPrice($_product, $_product->getPrice(), $_simplePricesTax); $_finalPrice = $_taxHelper->getPrice($_product, $_product->getFinalPrice()); $_finalPriceInclTax = $_taxHelper->getPrice($_product, $_product->getFinalPrice(), true); $_weeeDisplayType = $_weeeHelper->getPriceDisplayType(); if ($_finalPrice >= $_price) { if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)) { $returnPrice = $_price + $_weeeTaxAmount; } else { if ($_finalPrice == $_price) { $returnPrice = $_price; } else { $returnPrice = $_finalPrice; } } } else { $_originalWeeeTaxAmount = $_weeeHelper->getOriginalAmount($_product); if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)) { $returnPrice = $_regularPrice + $_originalWeeeTaxAmount; } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)) { $returnPrice = $_regularPrice + $_originalWeeeTaxAmount; } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 4)) { $returnPrice = $_regularPrice + $_originalWeeeTaxAmount; } elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 2)) { $returnPrice = $_regularPrice; } else { $returnPrice = $_finalPriceInclTax; } } } else { $_exclTax = $_taxHelper->getPrice($_product, $_minimalPriceValue); $_inclTax = $_taxHelper->getPrice($_product, $_minimalPriceValue, true); if ($_minimalPriceValue) { $_showPrice = $_inclTax; if (!$_taxHelper->displayPriceIncludingTax()) { $_showPrice = $_exclTax; } $returnPrice = $_showPrice; } } return $returnPrice; }
/** * 返回当前新增ID */ protected function getId() { return $this->_db->getId(); }