public function actionOperation() { $post = file_get_contents("php://input"); $postData = CJSON::decode($post, true); $this->_device->ifaces[$postData['iface_id']]->saveAttributes(array('lastactivity' => $postData['start'])); $operation = new Operation(); $postData['alarm'] = $postData['alarm'] ? 1 : 0; $operation->attributes = $postData; $transaction = Yii::app()->db->beginTransaction(); try { $operation->save(); $operation_id = $operation->id; foreach ($postData['records'] as $record) { $record['operation_id'] = $operation_id; $recordModel = new Record(); $recordModel->attributes = $record; $recordModel->save(); } $transaction->commit(); $this->_sendResponse(200); } catch (Exception $e) { $transaction->rollBack(); $this->_sendResponse(400); } }
/** * Сравнить Operation с ожидаемым массивом значений */ private function assertOperation(array $expected, Operation $op) { ksort($expected); $actual = array_intersect_key($op->toArray(false), $expected); ksort($actual); $this->assertEquals($expected, $actual); }
/** * De-index operation. * * @param Operation $operation * The operation to index. * @param string $key * (optional) The key to index under. * * @return Operation * The operation de-indexed. */ public function deIndex(Operation $operation, $key = null) { unset($this->operations[$operation->idx($this->connection)]); if (isset($key)) { unset($this->index[$key][$operation->idx($this->connection)]); } return $operation; }
public function update(Operation $operation) { $query = $this->_db->prepare('UPDATE t_operation SET date=:date, montant=:montant WHERE id=:id') or die(print_r($this->_db->errorInfo())); $query->bindValue(':date', $operation->date()); $query->bindValue(':montant', $operation->montant()); $query->bindValue(':id', $operation->id()); $query->execute(); $query->closeCursor(); }
/** * Возвращает операцию начального остатка * @return Operation */ private function getBalanceOperation() { if (is_null($this->balanceOperation)) { $params = array($this->getId(), Operation::TYPE_BALANCE); $this->balanceOperation = Doctrine_Query::create()->from('Operation o')->andWhere("account_id = ? AND type = ?", $params)->fetchOne(); if (!$this->balanceOperation) { $params = array('user_id' => $this->getUserId(), 'amount' => 0, 'date' => '0000-00-00', 'category_id' => NULL, 'type' => Operation::TYPE_BALANCE, 'comment' => 'Начальный остаток', 'accepted' => 1); $this->balanceOperation = new Operation(); $this->balanceOperation->fromArray($params); } $this->balanceOperation->setAccount($this); } return $this->balanceOperation; }
/** * Полное сообщение с описанием операции (для email) * * @param Operation $operation * @return Swift_Message */ private function _makeMessage(Operation $operation) { $from = array(sfConfig::get('app_notification_email_from') => sfConfig::get('app_notification_email_name')); $to = $operation->getUser()->getUserMail(); $subject = "Easyfinance.ru - напоминание об операции"; $body = sprintf($this->_template, $operation->getDateTimeObject('date')->format('d.m.y'), $operation->getCategory()->getName(), $operation->getAccount()->getName(), abs($operation->getAmount()), $operation->getAccount()->getCurrency()->getCode(), $operation->getComment()); return $this->_mailer->compose($from, $to, $subject, $body); }
public function actionIndex() { $operation = Operation::model()->findByAttributes(['module' => $this->getModule()->getId(), 'controller' => $this->getId(), 'action' => $this->getAction()->getId()]); if ($operation->getAttribute('level') == 1) { $maxLevel = 2; } else { $maxLevel = PHP_INT_MAX; } $operation = $this->auth->getOperationByPk($operation->getAttribute('id')); $child = $operation->getChild(); usort($child, function ($a, $b) { if ($a->getRawData('sort') == $b->getRawData('sort')) { return 0; } if ($a->getRawData('sort') < $b->getRawData('sort')) { return 1; } else { return 0; } }); $nav = array(); foreach ($child as $item) { if ($item->getStatus() || $item->getLevel() > $maxLevel) { continue; } $nav[] = [$item->getName(), $this->app->createUrl($item->getModule() . '/' . $item->getController() . '/' . $item->getAction())]; } $this->render('/public/nav', ['nav' => $nav]); }
public function start(Operation $op){ $rqs = $op->getRequestService(); $cs = $op->getContextService(); $ts = $op->getTransformService(); $rps = $op->getResponseService(); $model = $rqs->processRequest(); $context = $cs->getContext($model); $result = $ts->transform($context, $model); $context = $result[0]; $model = $result[1]; $cs->setContext($context); echo $rps->processResponse($model); }
public function __construct($operand = null, $operator = null, $OperationType = null) { parent::__construct(); $this->operand = $operand; $this->operator = $operator; $this->OperationType = $OperationType; }
public function __construct($operand = null, $exemptionRequests = null, $operator = null, $OperationType = null) { parent::__construct(); $this->operand = $operand; $this->exemptionRequests = $exemptionRequests; $this->operator = $operator; $this->OperationType = $OperationType; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Operation::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Lex an expression into Script tokens. * * @param string $string expression to lex * @param Context $context the context in which the expression is lexed * @return array tokens */ public function lex($string, $context) { // if it's already lexed, just return it as-is if (is_object($string)) { return [$string]; } if (is_array($string)) { return $string; } $tokens = []; // whilst the string is not empty, split it into it's tokens. while ($string !== FALSE) { if (($match = $this->isWhitespace($string)) !== FALSE) { $tokens[] = NULL; } elseif (($match = ScriptFunction::isa($string)) !== FALSE) { preg_match(ScriptFunction::MATCH_FUNC, $match, $matches); $args = []; foreach (ScriptFunction::extractArgs($matches[ScriptFunction::ARGS], FALSE, $context) as $key => $expression) { $args[$key] = $this->parser->evaluate($expression, $context); } $tokens[] = new ScriptFunction($matches[ScriptFunction::NAME], $args); } elseif (($match = Literals\Boolean::isa($string)) !== FALSE) { $tokens[] = new Literals\Boolean($match); } elseif (($match = Literals\Colour::isa($string)) !== FALSE) { $tokens[] = new Literals\Colour($match); } elseif (($match = Literals\Number::isa($string)) !== FALSE) { $tokens[] = new Literals\Number($match); } elseif (($match = Literals\SassString::isa($string)) !== FALSE) { $stringed = new Literals\SassString($match); $tokens[] = !strlen($stringed->quote) && Literals\SassList::isa($string) !== FALSE && !preg_match("/^\\-\\w+\\-\\w+\$/", $stringed->value) ? new Literals\SassList($string) : $stringed; } elseif ($string == '()') { $match = $string; $tokens[] = new Literals\SassList($match); } elseif (($match = Operation::isa($string)) !== FALSE) { $tokens[] = new Operation($match); } elseif (($match = Variable::isa($string)) !== FALSE) { $tokens[] = new Variable($match); } else { $_string = $string; $match = ''; while (strlen($_string) && !$this->isWhitespace($_string)) { foreach (Operation::$inStrOperators as $operator) { if (substr($_string, 0, strlen($operator)) == $operator) { break 2; } } $match .= $_string[0]; $_string = substr($_string, 1); } $tokens[] = new Literals\SassString($match); } $string = substr($string, strlen($match)); } return $tokens; }
public function testDeleteOldOperations() { // Create 10 operations $i = 0; for ($i = 0; $i < 10; $i++) { $op = new Operation(); $op->status = Operation::STATUS_SUCCEEDED; $op->timestamp = time(); $op->srcid = $i; $op->cmdid = '1234.' . $i; $op->optype = Operation::OPTYPE_IMPORTPDB; $op->operand1 = "C:\\Program Files\\Apache Software Foundations\\htdocs\\crashfix\\protected\\data\\debugInfo\\CrashRpt{$i}.pdb"; $op->operand2 = "C:\\Program Files\\Apache Software Foundations\\htdocs\\crashfix\\protected\runtime\tmp1234{$i}.tmp"; $this->assertTrue($op->save()); } // Delete old operations Operation::deleteOldOperations(5); // Expect there are 5 ops now $count = Operation::model()->count(); $this->assertTrue($count == 5); }
public function save() { try { if ($this->id) { $model = Operation::model()->findByPk($this->id); if (empty($model)) { throw new CDbException('参数出错', 1, []); } } else { $model = new Operation(); } $model->attributes = ['name' => $this->name, 'description' => $this->description, 'module' => $this->module, 'controller' => $this->controller, 'action' => $this->action, 'status' => $this->status, 'sort' => $this->sort]; if ($model->save() === false) { throw new CDbException('更新用户出错', 2, $model->getErrors()); } } catch (CDbException $e) { $this->addErrors($e->errorInfo); return false; } return true; }
public function actionDisplayOperation($id = null) { $model = Record::model()->findAllByAttributes(array('operation_id' => $id)); $values = CHtml::listData($model, 'port_id', 'value', 'timestamp'); $jsonarray = array(); foreach ($values as $date => $value) { $jsonarray[] = array_merge(array($date), $value); } $model = Operation::model()->with('iface')->findByPK($id); $model->nextPrev(); $this->render('displayOperation', array('values' => $jsonarray, 'operation' => $model)); }
/** * Вычисляет вклад операции в статью бюджета * @param Operation $operation * @return BudgetArticleIncrement */ public function calculate(Operation $operation) { $increment = new BudgetArticleIncrement(); //получаем модуль вклада операции в бюджет: //получаем без знака $signed = false; $operationContributionAmount = $operation->getAmountForBudget($this->_currency, $signed); if ($operation->getDate() < $this->_startDate->format('Y-m-d')) { $increment->mean += $operationContributionAmount / $this->_meanRateMonthsAmount; } else { if (!$operation->isFromCalendar()) { $increment->adhoc += $operationContributionAmount; } else { if ($operation->isAccepted()) { $increment->calendarAccepted += $operationContributionAmount; } else { $increment->calendarFuture += $operationContributionAmount; } } } return $increment; }
/** * @param Operation $operation * * @return self */ public function addOperation(Operation $operation) { $id = $operation->getMethod() . $operation->getPath(); $group = 0; if ($operation->getOperation()->getOperationId()) { $id = $operation->getOperation()->getOperationId(); } if ($operation->getOperation()->getTags() !== null && count($operation->getOperation()->getTags()) > 0) { $group = $operation->getOperation()->getTags()[0]; } if (!isset($this[$group])) { $this[$group] = []; } $this[$group][$id] = $operation; return $this; }
/** * Config */ public function configure() { $accounts = $this->getUser()->getUserRecord()->getAccounts()->toKeyValueArray('id', 'id'); $categories = $this->getUser()->getUserRecord()->getCategories()->toKeyValueArray('id', 'id'); $accounts[] = null; $categories[] = null; $this->setValidators(array('account_id' => new sfValidatorChoice(array('choices' => $accounts, 'required' => false, 'empty_value' => null), array('invalid' => 'No such account %value%')), 'category_id' => new sfValidatorChoice(array('choices' => $categories, 'required' => false, 'empty_value' => null), array('invalid' => 'No such category %value%')), 'amount' => new sfValidatorNumber(), 'date' => new sfValidatorDate(), 'type' => new sfValidatorChoice(array('choices' => Operation::getTypes())), 'comment' => new sfValidatorString(array('required' => false)), 'accepted' => new sfValidatorBoolean(array('empty_value' => 0)), 'created_at' => new myValidatorDatetimeIso8601(), 'updated_at' => new myValidatorDatetimeIso8601(), 'deleted_at' => new myValidatorDatetimeIso8601(array('required' => false)), 'transfer_account_id' => new sfValidatorChoice(array('choices' => $accounts, 'required' => false, 'empty_value' => null), array('invalid' => 'No such transfer account %value%')), 'transfer_amount' => new sfValidatorNumber())); if ($this->isNew()) { $this->setValidator('user_id', new sfValidatorPass()); } $this->validatorSchema->setOption('allow_extra_fields', true); $this->widgetSchema->setNameFormat('%s'); $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema); $this->disableLocalCSRFProtection(); }
public function __get($strName) { switch ($strName) { case 'ShortDescriptionAsHtml': $strToReturn = QApplication::HtmlEntities(trim($this->strShortDescription)); $strToReturn = str_replace("\r", '', $strToReturn); $strToReturn = str_replace("\n", '<br/>', $strToReturn); return $strToReturn; case 'Parameters': return $this->GetParameterArray(QQ::Clause(QQ::OrderBy(QQN::Parameter()->OrderNumber), QQ::Expand(QQN::Parameter()->Variable))); /* ONLY TO BE USED when OPERATION is restored via QcodoClass::Operations */ /* ONLY TO BE USED when OPERATION is restored via QcodoClass::Operations */ case 'InheritenceState': return $this->intInheritenceState; /* ONLY TO BE USED when OPERATION is restored via QcodoClass::Operations */ /* ONLY TO BE USED when OPERATION is restored via QcodoClass::Operations */ case 'OverridesOperation': return $this->objOverridesOperation; /* CAN BE USED ANYWHERE */ /* CAN BE USED ANYWHERE */ case 'Overrides': $objClass = $this->QcodoClass->ParentQcodoClass; while ($objClass) { if ($objOperation = Operation::LoadByQcodoClassIdQcodoInterfaceIdName($objClass->Id, null, $this->strName)) { return $objOperation; } $objClass = $objClass->ParentQcodoClass; } return null; case 'DisplayName': switch ($this->intInheritenceState) { case InheritenceState::Interited: return $this->strName . ' <img src="/images/inherited_light.png" border="0" alt="Inherited"/>'; case InheritenceState::Overrides: return $this->strName . ' <img src="/images/overrides.png" border="0" alt="Overrides"/>'; default: return $this->strName; } default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
protected function SetupOperation() { // Lookup Object PK information from Query String (if applicable) // Set mode to Edit or New depending on what's found $intId = QApplication::QueryString('intId'); if ($intId) { $this->objOperation = Operation::Load($intId); if (!$this->objOperation) { throw new Exception('Could not find a Operation object with PK arguments: ' . $intId); } $this->strTitleVerb = QApplication::Translate('Edit'); $this->blnEditMode = true; } else { $this->objOperation = new Operation(); $this->strTitleVerb = QApplication::Translate('Create'); $this->blnEditMode = false; } }
static function __static() { self::$plus = newinstance(__CLASS__, array(0, 'plus'), '{ static function __static() { } public function evaluate($x, $y) { return $x + $y; } }'); self::$minus = newinstance(__CLASS__, array(1, 'minus'), '{ static function __static() { } public function evaluate($x, $y) { return $x - $y; } }'); self::$times = newinstance(__CLASS__, array(2, 'times'), '{ static function __static() { } public function evaluate($x, $y) { return $x * $y; } }'); self::$divided_by = newinstance(__CLASS__, array(3, 'divided_by'), '{ static function __static() { } public function evaluate($x, $y) { return $x / $y; } }'); }
/** * This method deletes all completed operations not in top count. * @param type $topCount Count of recent operations to keep. * @return void */ public static function deleteOldOperations($topCount = 1000) { // Get total count of records $totalCount = Operation::model()->count(); $limitCount = $totalCount - $topCount; if ($limitCount <= 0) { return; } // Do nothing // Select the oldest operation records for deleting $criteria = new CDbCriteria(); $criteria->select = '*'; $criteria->compare('status', '<>' . self::STATUS_STARTED); $criteria->order = 'timestamp DESC'; $criteria->limit = $limitCount; $ops = Operation::model()->findAll($criteria); foreach ($ops as $op) { $op->delete(); } }
public function view() { $roleId = $this->request->getPost('role', 0); $role = $this->auth->getRoleByPk($roleId); if ($role == false) { $this->response(404, '参数错误'); } else { $operations = Operation::model()->findAll(['condition' => '`level`=2']); $opera = []; foreach ($operations as $operation) { $auth = $this->auth->getOperationByPk($operation->getAttribute('id')); $opera[] = ['data' => $auth, 'child' => $auth->getChild()]; } $assigns = $role->getAssigns(); $assign = []; foreach ($assigns as $item) { if ($item !== false) { $assign[] = $item->getId(); } } $this->render('assign', ['opera' => $opera, 'role' => $role, 'assign' => $assign]); } }
public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects) { if ($objObject->objOperation) { $objObject->objOperation = Operation::GetSoapObjectFromObject($objObject->objOperation, false); } else { if (!$blnBindRelatedObjects) { $objObject->intOperationId = null; } } if ($objObject->objVariable) { $objObject->objVariable = Variable::GetSoapObjectFromObject($objObject->objVariable, false); } else { if (!$blnBindRelatedObjects) { $objObject->intVariableId = null; } } return $objObject; }
/** * Remove operation. * * @param Operation $operation * The operation to remove from the connection. */ public function removeOperation(Operation $operation) { $operation->remove($this); unset($this->operations[$operation->idx($this)]); }
public function __construct($operand = NULL, $operator = NULL, $OperationType = NULL) { if (get_parent_class('ConversionTrackerOperation')) { parent::__construct(); } $this->operand = $operand; $this->operator = $operator; $this->OperationType = $OperationType; }
public function __construct($operand = NULL, $operator = NULL, $OperationType = NULL) { if (get_parent_class('CampaignTargetOperation')) { parent::__construct(); } $this->operand = $operand; $this->operator = $operator; $this->OperationType = $OperationType; }
public function __construct($srcPath, $dstPath) { parent::__construct($srcPath, self::MOVE_NODE); $this->dstPath = $dstPath; }
protected function get_persons_graph_drilldown_json($person_id, $filter_orderby) { $operations = new Operation(); $operations->select('*'); $operations->where_related_person('id', (int) $person_id); $operations->order_by('created', 'asc'); $operations->include_related('product_quantity'); $operations->include_related('product_quantity/product'); $operations->include_related('service_usage'); $operations->include_related('service_usage/service'); $operations->get_iterated(); $series = array(); $days = array(); $days_plus_amount = array(); $days_minus_amount = array(); $current_day_index = ''; foreach ($operations as $operation) { $day_index = date('d.m.Y', strtotime($operation->created)); if ($day_index != $current_day_index) { $days_plus_amount[$day_index] = 0; $days_minus_amount[$day_index] = 0; $days[] = $day_index; $current_day_index = $day_index; } if ($operation->type == Operation::TYPE_ADDITION && (int) $operation->amount > 0) { $days_plus_amount[$day_index] += (double) $operation->amount; } elseif ($operation->type == Operation::TYPE_SUBTRACTION) { if ($operation->subtraction_type == Operation::SUBTRACTION_TYPE_DIRECT && (double) $operation->amount > 0) { $days_minus_amount[$day_index] += (double) $operation->amount; } elseif ($operation->subtraction_type == Operation::SUBTRACTION_TYPE_PRODUCTS && !is_null($operation->product_quantity_id) && !is_null($operation->product_quantity_product_id) && (double) $operation->product_quantity_quantity * (double) $operation->product_quantity_price > 0) { $days_minus_amount[$day_index] += (double) $operation->product_quantity_quantity * (double) $operation->product_quantity_price; } elseif ($operation->subtraction_type == Operation::SUBTRACTION_TYPE_SERVICES && !is_null($operation->service_usage_id) && !is_null($operation->service_usage_service_id) && (double) $operation->service_usage_quantity * (double) $operation->service_usage_price > 0) { $days_minus_amount[$day_index] += (double) $operation->service_usage_quantity * (double) $operation->service_usage_price; } } } $total_plus = 0; $total_minus = 0; $series_item_start = new stdClass(); $series_item_start->name = 'Začiatok sústredenia'; $series_item_start->y = 0; $series[] = $series_item_start; if (count($days) > 0) { foreach ($days as $day) { $series_item = new stdClass(); $series_item->name = $day; if ($filter_orderby == 'amount_left') { $total_plus += $days_plus_amount[$day]; $total_minus += $days_minus_amount[$day]; $series_item->y = $total_plus - $total_minus; } elseif ($filter_orderby == 'amount_acquired') { $series_item->y = $days_plus_amount[$day]; } else { $series_item->y = $days_minus_amount[$day]; } if ($series_item->y > 0 || $filter_orderby == 'amount_left') { $series[] = $series_item; } } } $series_item_end = new stdClass(); $series_item_end->name = 'Koniec sústredenia'; $series_item_end->y = 0; $series[] = $series_item_end; return $series; }
/** * @before _secure, _vendor */ public function settings() { $this->seo(array("title" => "Settings", "view" => $this->getLayoutView())); $view = $this->getActionView(); $centre = Centre::first(array("id = ?" => $this->member->centre_id)); $location = Location::first(array("id = ?" => $centre->location_id)); $area = Area::first(array("id = ?" => $location->area_id)); if (RequestMethods::post("action") == "settings") { $phone = RequestMethods::post("phone"); $user = $this->user; $message = null; if ($phone != $user->phone) { $exist = User::first(array("phone = ?" => $phone)); if ($exist) { $message = "Phone number already exists"; } else { $user->phone = $phone; } } $user->name = RequestMethods::post("name"); $user->save(); $this->setUser($user); $location = \Location::saveRecord($user, $location); $phone = RequestMethods::post("cphone"); if ($centre->phone != $phone) { $exist = Centre::first(array("phone = ?" => $phone)); if ($exist) { $message = "Landline already exists!!"; } else { $centre->phone = $phone; $centre->save(); } } if (!$message) { $message = "Info updated!!"; } $view->set("message", $message); } if (RequestMethods::post("action") == "operations") { $operations = RequestMethods::post("operations"); foreach ($operations as $key => $value) { $operation = Operation::first(array("centre_id = ?" => $id, "area_id = ?" => $value)); if (!$operation) { $operation = new Operation(array("user_id" => $this->user->id, "centre_id" => $id, "organization_id" => $this->organization->id, "area_id" => $value, "live" => 1)); $operation->save(); } } } $ops = Operation::all(array("centre_id = ?" => $id), array("area_id")); $opa = array(); foreach ($ops as $o) { $opa[] = $o->area_id; } $view->set("centre", $centre); $view->set("area", $area); $view->set("location", $location); $view->set("opa", $opa); }