/** * Constructor * @param type $a_parent_obj * @param type $a_parent_cmd * @param type $a_template_context */ public function __construct($a_parent_obj_gui, $a_parent_obj, $a_parent_cmd) { $this->parent_container = $a_parent_obj; $this->setId('lomemtstres_' . $a_parent_obj->getId()); parent::__construct($a_parent_obj_gui, $a_parent_cmd); $this->settings = ilLOSettings::getInstanceByObjId($a_parent_obj->getId()); }
/** * * @param type $order * @return string */ public function cancelOrderUrl($order, $recurring = false) { $url = Mage::getUrl('recurring/orders/delete'); if ($recurring) { $url .= '?options[' . self::OPTIONSID . '][recurring_id]=' . $order->getId(); } else { $url .= '?options[' . self::OPTIONSID . '][order_id]=' . $order->getId(); } $url .= '&options[' . self::OPTIONSID . '][deleteorder]=1'; $url .= '" onClick="return confirm(\'Are you sure that you want to delete this order?\');'; return $url; }
/** * Convert to form value. * * @param type $value */ public function transform($value) { if ($value === null) { return; } return $value->getId(); }
/** * if webcomm boilerplate is used, we can use bootstrap modals * @param type $agreement * @return type */ public function getBoilerplateLinkedText($agreement) { $text = Mage::helper('core')->escapeHtml($agreement->getCheckboxText(), null); foreach ($this->getKeywords() as $word) { $text = str_replace($word, '<a href="#" data-toggle="modal" data-target="#agreement-content-' . $agreement->getId() . '" >' . $word . '</a>', $text); } return $text; }
/** * saving after teacher_signup * * @param type $object * @return boolean */ public function saveTeacher($object) { if ($object->getId() == null) { $object->setCreated(new \DateTime('now')); $object->setActive(true); $object->setCategory('t'); } $this->getEntityManager()->merge($object); $this->getEntityManager()->flush(); return true; }
/** * Get Sub units chain * @param type $node parent subunit * @return string Chain of subunits ids, separated by commas */ public function getSubUnitsChain($node) { $value = $node->getId(); $children = $node->getNode()->getChildren(); if ($children !== false) { foreach ($children as $childNode) { $value = $value . "," . $this->getSubUnitsChain($childNode); } } return $value; }
/** * @param type $tree tree * @param type $begin begin * @param type &$end end * @param type $em em */ public function postOrderTraversal($tree, $begin, &$end, $em) { //get $tree childrens $children = $em->getRepository('CMSAdminBUndle:Menu')->getChildren($tree->getId()); $tree->setLft($begin); $end = ++$begin; //Travesal the tree foreach ($children as $child) { $repositor = $em->getRepository('CMSAdminBUndle:Menu'); $repositor->postOrderTraversal($child, $begin, $end, $em); $begin = ++$end; } $tree->setRgt($end); }
/** * Update an item * @param type $basketObj * @return type */ public static function updateBasket($basketObj) { $userId = \Core\Db::escape($basketObj->getUserId()); $petId = \Core\Db::escape($basketObj->getPetId()); $id = $basketObj->getId(); $sql = <<<q UPDATE `basket` SET `user_id` = '{$userId}', `pet_id` = '{$petId}' WHERE `id` = {$id}; q; //echo "<br/><br/>" . $sql . "<br/><br/>"; $res = \Core\Db::execute($sql); return $res === false ? false : true; }
/** * Get most recent birthday transfer linked to a provided customer * Returns null if no fransfer is found * * @param type $customer * @return type */ public function getMostRecentBirthdayTransfer($customer) { // latest birthday transfer $birthdayTransfers = $this->getTransfersAssociatedWithBirthday()->addFilter('customer_id', $customer->getId())->load(); $latest_transfer = null; foreach ($birthdayTransfers as $transfer) { if (null == $latest_transfer) { $latest_transfer = $transfer; } if (strtotime($transfer->getCreationTs()) >= strtotime($latest_transfer->getCreationTs())) { $latest_transfer = $transfer; } } return $latest_transfer; }
/** * Функция выбирает варианты событий для заданной комнаты, по которым не было оповещений за $minDelay * проверяет выходы параметров за пределы, отправляет уведомления, * @param type $s * @param type $room * @return type */ public function checkEvents($s, $room) { $em = $this->getEntityManager(); $n = new \DateTime("now", new \DateTimeZone("Europe/Moscow")); $this->ev_time = $n->sub(new \DateInterval($this->minDelay)); $qb = $em->createQueryBuilder(); $qb->select('e', 'max(h.evTime)')->from('AppBundle:Events', 'e')->leftJoin('AppBundle:Histories', 'h', \Doctrine\ORM\Query\Expr\Join::WITH, 'h.ev=e.id')->join('e.room', 'r')->join("e.userid", "u")->where("e.room = :room")->groupBy('e.id')->setParameter('room', $room->getId()); $query = $qb->getQuery(); $ev = $query->getResult(); $stat = $s[0]; foreach ($ev as $e) { $last = isset($e[1]) ? new \DateTime($e[1], new \DateTimeZone("Europe/Moscow")) : new \DateTime("2012-07-08"); $this->checkT($e, $stat, $last); $this->checkH($e, $stat, $last); $this->checkCO2($e, $stat, $last); $this->checkVOC($e, $stat, $last); } return $this->sendEvents(); }
/** * Adds column to filter list if needed * @param type $column Column to filter * @return TinyBrick_OrderEdit_Block_Adminhtml_Sales_Order_Edit_Search_Grid */ protected function _addColumnFilterToCollection($column) { // Set custom filter for in product flag if ($column->getId() == 'in_products') { $productIds = $this->_getSelectedProducts(); if (empty($productIds)) { $productIds = 0; } if ($column->getFilter()->getValue()) { $this->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds)); } else { if ($productIds) { $this->getCollection()->addFieldToFilter('entity_id', array('nin' => $productIds)); } } } else { parent::_addColumnFilterToCollection($column); } return $this; }
/** * Update the data of an existing user * @param type $userObj an instance of the User class * @return type boolean false if update fails, true otherwise */ public static function updateUser($userObj) { $id = $userObj->getId(); $username = \Core\Db::escape($userObj->getUsername()); $password = \Core\Db::escape($userObj->getPassword()); $email = \Core\Db::escape($userObj->getEmail()); $created = $userObj->getCreated(); $updated = time(); $isAdmin = $userObj->getIsAdmin(); $lastLogin = \Core\Db::escape($userObj->getLastLogin()); $sql = <<<q UPDATE `user` SET `username` = '{$username}', `password` = '{$password}', `email` = '{$email}', `created` = {$created}, `updated` = {$updated}, `is_admin` = {$isAdmin}, `last_login` = '{$lastLogin}' WHERE `id` = {$id}; q; $res = \Core\Db::execute($sql); return $res === false ? false : true; }
/** * returns right side blocks filtered by pageType / object * * @param type $pageType * @param type $object * @param type $path * @return type */ public function getRightSideBlocks($pageType, $object) { if ($object == null || $pageType == null) { return null; } $containerFilters = array('pageType' => $pageType, 'active' => true); $containerFilters['id'] = $object->getId(); $containerFilters['categories'] = array(); if ($object->getCategory() != null) { $containerFilters['categories'][] = $object->getCategory()->getId(); } if ($object->getSubcategory() != null) { $containerFilters['categories'][] = $object->getSubcategory()->getId(); } $containers = $this->getPageBlockContainers($containerFilters); $blocks = $this->getPageBlocksFromContainers($containers); //foreach ($containers as $c) { // var_dump($c->getId()); //}die; // foreach ($blocks as $c) { // var_dump($c); // }die; return $blocks; }
/** * * @param type $trabajador * @return boolean */ public function evaluateWorkerBeginMiss($trabajador) { $nextWD = $this->nextWorkingDay($trabajador->getId()); if (!$nextWD) { //En caso de que el trabajador no contenga ningun registro anterior return false; } $horario = $trabajador->getHorario(); $nextWD->setTimezone(new \DateTimeZone($horario->getTimeZone())); $actual = new \DateTime('now'); $actual->setTimezone(new \DateTimeZone($horario->getTimeZone())); if ($this->horarioManager->equalDates($nextWD, $actual)) { $eval = $this->horarioManager->evaluateTime($horario->getId(), $actual); if (!$eval) { $this->registroManager->beginWork($trabajador->getId(), $actual, 'not_mark', false); } } }
/** * Удалить изображение * @param type $oPhoto * @return type */ public function deleteTopicPhoto($oPhoto) { $this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array("photoset_photo_update")); $this->oMapperTopic->deleteTopicPhoto($oPhoto->getId()); @unlink($this->Image_GetServerPath($oPhoto->getWebPath())); $aSizes = Config::Get('module.topic.photoset.size'); // Удаляем все сгенерированные миниатюры основываясь на данных из конфига. foreach ($aSizes as $aSize) { $sSize = $aSize['w']; if ($aSize['crop']) { $sSize .= 'crop'; } @unlink($this->Image_GetServerPath($oPhoto->getWebPath($sSize))); } return; }
/** * * @param type $object entiteta * @param type $params */ public function delete($object) { /** * matičnega gledališča ni mogoče brisati */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $optionR = $em->getRepository('App\\Entity\\Option'); $option = $optionR->findOneByName("application.tenant.maticnopodjetje"); $popaId = $option->getDefaultValue(); // šifra matičnega podjetja t.j. lastnega gledališča $this->expect($object->getId() != $popaId, "Matičnega gledališča ni mogoče brisati", 1001210); parent::delete($object); }
/** * * @param type $review */ public function createRatings($review) { $jobTitleId = $review->getEmployee()->getJobTitle()->getId(); $parameters['jobCode'] = $review->getEmployee()->getJobTitle()->getId(); $kpis = $this->getKpiService()->searchKpiByJobTitle($parameters); foreach ($review->getReviewers() as $reviewer) { foreach ($kpis as $kpi) { $rating = new ReviewerRating(); $rating->setReviewId($review->getId()); $rating->setKpiId($kpi->getId()); $rating->setReviewerId($reviewer->getId()); $review->getReviewerRating()->add($rating); } } return $review; }
/** * Monta a URL de edição a partir da entidade. OBS: esse método só pode ser chamado dentro do edit(). * * @param Request $request * @param type $entity */ protected function editUrl(Request $request, $entity) { $route = $request->get('_route'); return $this->generateUrl($route, ['id' => $entity->getId()]); }
/** * Doda spremembo kolekcije v $this->changes * * @param type $entity lastnik kolekcije * @param type $type tip spremembe entitete ('INS' 'UPD', 'DEL') * @param type $field polje kolekcije * @param type $op operacija ('+' ali '-') * @param type $inverseEntity entiteta dodana v kolekcijo */ protected function addCollectionChange($entity, $type, $field, $op, $inverseEntity) { $this->initChange($entity, $type); $id = $entity->getId(); $this->changes[$id]['data'][$field][] = [$op, $inverseEntity->getId()]; }
/** * Create one element * * @param type $node */ private function _generateElement($node) { if (!$node->isAllow()) { return; } $cssClasses = array(); $cssActive = ''; if ($node->isActive()) { $cssActive = 'class="active"'; } if (!is_null($node->getClass())) { $cssClasses[] = $node->getClass(); } $class = count($cssClasses) > 0 ? " class='" . implode(',', $cssClasses) . "'" : ''; $id = !is_null($node->getId()) ? " id='" . $node->getId() . "'" : ''; $target = !is_null($node->getTarget()) ? " target='" . $node->getTarget() . "'" : ''; $this->html .= "\t\t" . '<li ' . $cssActive . '>' . PHP_EOL; if (!$node->hasChilds()) { $this->html .= "\t\t\t" . '<a href="' . $node->getUrl() . '" ' . $target . ' class="nav-header" ><span' . $class . '></span> ' . $this->_translate($node->getName()) . "</a>" . PHP_EOL; } //generate childs if ($node->hasChilds()) { //$this->html .= "\t\t<div class='dropdown'>" . PHP_EOL; $this->html .= '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' . $this->_translate($node->getName()) . ' <span class="caret"></span></a>' . PHP_EOL; $this->html .= "\t\t<ul class=\"dropdown-menu\">" . PHP_EOL; $this->_generateChilds($node->getChilds()); $this->html .= "\t\t</ul>" . PHP_EOL; //$this->html .= "\t\t</div>" . PHP_EOL; } $this->html .= "\t\t</li>" . PHP_EOL; }
/** * Salva uma avalição do verificador * @param type $evaluationRow * @param type $linhas1 * @param type $linhas2 * @param type $answers * @param type $finalizar * @return type * @throws Exception */ public function saveCheckerEvaluation($commentQuestions, $evaluationQuestions, $evaluationRow, $comments = array(), $answers = array(), $conclusao = '', $finalizar = false) { $tbCheckerEvaluation = DbTable_CheckerEvaluation::getInstance(); $checkerEnterpriseId = $evaluationRow->getId(); $finalizacaoSucesso = true; $criteriosError = $evaluationQuestionsError = array(); Zend_Registry::get('db')->beginTransaction(); try { $evaluationRow->setStatus('I')->save(); $tbCheckerEvaluation->delete(array('CheckerEnterpriseId = ?' => $checkerEnterpriseId)); $qtdePontosForte = 0; foreach ($evaluationQuestions as $question) { $questionId = $question['Id']; if (!isset($answers[$questionId])) { $finalizacaoSucesso = false; $evaluationQuestionsError[$questionId] = array(); continue; } $resposta = isset($answers[$questionId]) ? $answers[$questionId] : null; if ($resposta == 'F') { $qtdePontosForte++; } $checkerEntRow = $tbCheckerEvaluation->createRow()->setCheckerEnterpriseId($checkerEnterpriseId)->setQuestionCheckerId($questionId)->setResposta($resposta)->setCheckerEvaluationTypeId(2); $checkerEntRow->save(); } if ($conclusao) { $evaluationRow->setConclusao($conclusao)->setConclusaoDate(new Zend_Db_Expr('NOW()'))->setQtdePontosFortes($qtdePontosForte)->save(); } $criterioAnterior = ''; foreach ($commentQuestions as $question) { $criterio = "{$question->getBloco()}{$question->getCriterio()}"; if ($criterioAnterior == $criterio) { continue; } $criterioAnterior = $criterio; if (!isset($comments[$criterio]) or trim($comments[$criterio]) == '') { $finalizacaoSucesso = false; $criteriosError[$question->getBloco()][$question->getCriterio()] = array(); continue; } $checkerEntRow = $tbCheckerEvaluation->createRow()->setCheckerEnterpriseId($checkerEnterpriseId)->setCriterionNumber($criterio)->setComment($comments[$criterio])->setCheckerEvaluationTypeId(1); $checkerEntRow->save(); } if ($finalizar and $finalizacaoSucesso and $conclusao and $qtdePontosForte) { $evaluationRow->setQtdePontosFortes($qtdePontosForte)->setStatus('C')->save(); } Zend_Registry::get('db')->commit(); return array('status' => true, 'finalizacaoSucesso' => $finalizacaoSucesso, 'criteriosError' => $criteriosError, 'evaluationQuestionsError' => $evaluationQuestionsError); } catch (Exception $e) { Zend_Registry::get('db')->rollBack(); throw new Exception($e); } }
/** * отключает пакет услуг от услуги или счета * * @param \Billing\Domain\TVEIpTVChannel $object * @param type $account * @param type $serviceAccount */ static function dis(TVEIpTVChannel $object, $account, $serviceAccount = null) { $st = \Billing\Core::getEm()->getConnection()->prepare("exec ServiceAccountPeriodObjectDis :ServiceAccountID, :AccountNumber, :ObjectID"); $st->bindValue(":ServiceAccountID", $serviceAccount ? $serviceAccount->getId() : null); $st->bindValue(":AccountNumber", $account ? $account->getNumber() : null); $st->bindValue(":ObjectID", $object->getId()); $result = $st->execute(); }
/** * * @param type $document */ public function getSubFormModels($document = null) { $subforms = $this->getSubForms(); $persons = array(); foreach ($subforms as $name => $subform) { $person = $subform->getLinkModel($document->getId(), $this->_roleName); // TODO should return Link Objekt $persons[] = $person; } return $persons; }
/** * Send a message to a single device * @param type $device * @return \Push_Model_Android_Message * @throws Exception */ public function sendMessage($device) { $error = false; $registration_ids = array(); $registration_ids[] = $device->getRegistrationId(); //TTL 604800 = 1 semaine try { $status = 0; $fields = array('registration_ids' => $registration_ids, 'data' => array('time_to_live' => 0, 'delay_while_idle' => false, 'message' => $this->getMessage()->getText(), 'latitude' => $this->getMessage()->getLatitude(), 'longitude' => $this->getMessage()->getLongitude(), 'radius' => $this->getMessage()->getRadius(), 'message_id' => $this->getMessage()->getMessageId())); $headers = array('Authorization: key=' . $this->__key, 'Content-Type: application/json'); // Open connection $ch = curl_init(); // Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $this->__url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Disabling SSL Certificate support temporarly curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, Zend_Json::encode($fields)); // Execute post $result = curl_exec($ch); if ($result === FALSE) { // $this->getMessage()->updateStatus('failed'); $errors = $this->getErrors(); if (empty($errors)) { $errors = array(); } $errors[$device->getId()] = $e; $this->setErrors($errors); $error = true; } else { $status = 1; } // Close connection curl_close($ch); } catch (Exception $e) { $errors = $this->getErrors(); if (empty($errors)) { $errors = array(); } $errors[$device->getId()] = $e; $this->setErrors($errors); $error = true; } if (!$error) { $this->getMessage()->createLog($device, $status, $device->getRegistrationId()); } }
/** * SEt the User * @param type $user * @return \DxUser\Entity\UserProfile */ public function setUser($user) { $this->user = $user; $this->userId = $user->getId(); return $this; }
/** * * @param type $entity * @return type */ private function defaultDelete($entity) { $id = $entity->getId(); $this->getEntityManager()->remove($entity); $this->getEntityManager()->flush(); return $id; }
/** * Возвращает пользователя БД * @param type $user * @return type */ static function getUser($user) { return TDataBaseUser::getUserById($user->getId()); }
/** * Changed By Adam to solve the problem of partial refund 26/08/2014 * @param type $creditmemo * @return \Magestore_Affiliateplus_Model_Transaction */ public function reduce($creditmemo) { if ($this->getStatus() == 1) { if ($this->canRestore()) { return $this; } // edit by viet if (!$this->getId() || !$creditmemo->getId()) { return $this; } $reducedIds = explode(',', $this->getCreditmemoIds()); if (is_array($reducedIds) && in_array($creditmemo->getId(), $reducedIds)) { return $this; } $reducedIds[] = $creditmemo->getId(); // calculate reduced commission $reduceCommission = 0; // Reduce commission for affiliate level 0 $reduceTransactionCommission = 0; // Reduce commission for transaction (all affiliate + tier affiliate) $reduceTransactionDiscount = 0; foreach ($creditmemo->getAllItems() as $item) { if ($item->getOrderItem()->isDummy()) { continue; } // Calculate the reduce commission for affiliate if (!$item->getAffiliateplusCommissionFlag()) { $orderItem = $item->getOrderItem(); if ($orderItem->getAffiliateplusCommission()) { // Calculate the reduce commission for affiliate $affiliateplusCommissionItem = explode(",", $orderItem->getAffiliateplusCommissionItem()); $firstComs = $affiliateplusCommissionItem[0]; $reduceCommission += $firstComs * $item->getQty() / $orderItem->getQtyOrdered(); // Calculate the reduce commission for transaction $orderItemQty = $orderItem->getQtyOrdered(); $orderItemCommission = (double) $orderItem->getAffiliateplusCommission(); if ($orderItemCommission && $orderItemQty) { $reduceTransactionCommission += $orderItemCommission * $item->getQty() / $orderItemQty; } $reduceTransactionDiscount += $orderItem->getBaseAffiliateplusAmount() * $item->getQty() / $orderItemQty; $item->setAffiliateplusCommissionFlag(1)->save(); Mage::dispatchEvent('update_tiercommission_to_tieraffiliate_partial_refund', array('transaction' => $this, 'creditmemo_item' => $item)); } } } if ($reduceCommission <= 0) { return $this; } // check reduced commission is over than total commission if ($reduceTransactionCommission > $this->getCommission()) { $reduceTransactionCommission = $this->getCommission(); } $account = Mage::getModel('affiliateplus/account')->setStoreId($this->getStoreId())->load($this->getAccountId()); try { // $commission = $reduceCommission + $this->getCommissionPlus() * $reduceCommission / $this->getCommission() + $reduceCommission * $this->getPercentPlus() / 100; // $commission = $reduceCommission + $this->getCommissionPlus() * $reduceTransactionCommission / $this->getCommission() + $reduceTransactionCommission * $this->getPercentPlus() / 100; if ($commission) { $account->setBalance($account->getData('balance') - $commission)->save(); // $account->setBalance($account->getBalance() - $commission) // ->save(); } $creditMemoIds = implode(',', array_filter($reducedIds)); $this->setCreditmemoIds($creditMemoIds); $this->setCommissionPlus($this->getCommissionPlus() - $this->getCommissionPlus() * $reduceTransactionCommission / $this->getCommission()); $order = $creditmemo->getOrder(); if ($reduceTransactionCommission) { if ($this->getCommission() <= $reduceTransactionCommission && $order->getBaseSubtotal() == $order->getBaseSubtotalRefunded()) { $this->setCommission(0)->setStatus(3); } else { $this->setCommission($this->getCommission() - $reduceTransactionCommission); } } if ($reduceTransactionDiscount) { if ($this->getDiscount() > $reduceTransactionDiscount) { $this->setDiscount(0); } else { $this->setDiscount($this->getDiscount() + $reduceTransactionDiscount); } } $this->save(); if ($reduceTransactionCommission) { // Update affiliateplusprogram transaction Mage::dispatchEvent('update_affiliateplusprogram_transaction_partial_refund', array('transaction' => $this, 'creditmemo' => $creditmemo)); // update balance for tier transaction $commissionObj = new Varien_Object(array('base_reduce' => $reduceTransactionCommission, 'total_reduce' => $commission)); Mage::dispatchEvent('affiliateplus_reduce_transaction', array('transaction' => $this, 'creditmemo' => $creditmemo, 'commission_obj' => $commissionObj)); $reduceCommission = $commissionObj->getBaseReduce(); // Tong commission se bi tru di o transaction $commission = $commissionObj->getTotalReduce(); // Tong commission se bi tru di khoi tai khoan customer // Send email for affiliate account $this->sendMailReduceCommissionToAccount($reduceCommission, $commission); } } catch (Exception $e) { print_r($e->getMessage()); die('zzz'); } } return $this; }
/** * * @param type $entity * @param type $returnPartial * @param type $extra * @return type */ private function administratorGet($entity, $returnPartial = false, $extra = null) { return $this->defaultGet($entity->getId(), $returnPartial, $extra); }
/** * Get banner positions by slider id * * @param type $slider * @return type */ public function getBannerPosition($slider) { $select = $this->_getWriteAdapter()->select()->from(array('main_table' => $this->_referenceTable), array('banner_id', 'position'))->where('main_table.slider_id = ?', 1); $bind = array('slider_id' => (int) $slider->getId()); return $this->_getWriteAdapter()->fetchPairs($select, $bind); }