Esempio n. 1
0
 public function loadById($id)
 {
     if (isNull($object = $this->_mapper->storage()->loadObjectById($id))) {
         return $this->_mapper->getDefaultGroup();
     }
     return $object;
 }
Esempio n. 2
0
function transfer()
{
    $query = M('Db')->createQuery('tmp_equipment_export')->what('city_id, user_id, scaner_id, modem_id, laptop_id')->where('`exit` IS NULL OR `exit` = ""');
    $request = M('Store')->requestQuery(M('Store')->factoryObject(), $query);
    $transfer = 0;
    foreach ($request as $object) {
        if (!isNull($obHolder = getHolderByUserId($object->user_id))) {
            if (!isNull($obEquipment = M('Equipment')->loadById($object->scaner_id))) {
                if ($obEquipment->holder_id != $obHolder->id) {
                    $obEquipment->setHolder($obHolder);
                    $obEquipment->save();
                    $transfer++;
                }
            }
            if (!isNull($obEquipment = M('Equipment')->loadById($object->modem_id))) {
                if ($obEquipment->holder_id != $obHolder->id) {
                    $obEquipment->setHolder($obHolder);
                    $obEquipment->save();
                    $transfer++;
                }
            }
            if (!isNull($obEquipment = M('Equipment')->loadById($object->laptop_id))) {
                if ($obEquipment->holder_id != $obHolder->id) {
                    $obEquipment->setHolder($obHolder);
                    $obEquipment->save();
                    $transfer++;
                }
            }
        }
    }
    echo "\n\nTRANSFER: {$transfer} enities";
}
Esempio n. 3
0
 protected function _list()
 {
     if (isNull($this->_list)) {
         $this->_list = M('List')->loadById($this->_list_id);
     }
     return $this->_list;
 }
Esempio n. 4
0
/**
 *	Returns logged user or anonymous user.
 *
 *	@return		RM_Account_iUser
 */
function me()
{
    if (isNull($result = M('Account')->getLoggedUser())) {
        $result = M('Account')->getAnonymousUser();
    }
    return $result;
}
Esempio n. 5
0
 protected function _isAddToModeration()
 {
     $barcode = $this->_object->getBarcode();
     if (!M('Purchase')->isInStopList($this->_object->barcode_value) && (isNull($barcode = $this->_object->getBarcode()) || $barcode->attribute_1 != $this->_object->corrected_name)) {
         return TRUE;
     }
 }
Esempio n. 6
0
 function depth($input_data, $path = null, $depth = 0)
 {
     /*
      Returns the depth of the node that reaches the input data instance
      when ran through the tree, and the associated set of rules.
     
      If a node has any children whose
      predicates are all true given the instance, then the instance will
      flow through that child.  If the node has no children or no
      children with all valid predicates, then it outputs the depth of the
      node.
     */
     if (isNull($path)) {
         $path = array();
     }
     # root node: if predicates are met, depth becomes 1, otherwise is 0
     if ($depth == 0) {
         if (!$this->predicates->apply($input_data, $this->fields)) {
             return array($depth, $path);
         }
         $depth += 1;
     }
     if ($this->children != null) {
         foreach ($this->children as $child) {
             if ($child->predicates->apply($input_data, $this->fields)) {
                 $array_push($path, $child->predicates->to_rule($this->fields));
                 return $child->depth($input_data, $path, $depth + 1);
             }
         }
     }
     return array($depth, $path);
 }
Esempio n. 7
0
 public function loadCategoryByName($name)
 {
     if (!isNull($object = $this->_mapper->loadCategoryByName($name))) {
         $this->_mapper->access($object, 'CATEGORY.USE');
     }
     return $object;
 }
Esempio n. 8
0
 public function getCaptionByVarname($name)
 {
     if (!isNull($value = $this->loadObjectByName($name))) {
         return $value->getCaption();
     }
     return L('list.value.' . $name);
 }
Esempio n. 9
0
 /**
  *	Description...
  *
  *	@return void
  **/
 public function loadReportById($id)
 {
     if (!isNull($object = $this->_mapper->storage('total')->loadObjectById($id))) {
         $this->_mapper->access($object, 'READ');
     }
     return $object;
 }
Esempio n. 10
0
 /**
  * Enter description here...
  *
  * @return RM_Diagram_Object
  */
 protected function get()
 {
     if (!$this->_diagram && isNull($this->_diagram = M('Diagram')->loadDiagramByName($this->_name))) {
         $this->create();
     }
     return $this->_diagram;
 }
Esempio n. 11
0
 public function getDiagramList()
 {
     $obData = $this->getData();
     $obData->setColumnsForRowDescribe();
     $obData->hideColumns(REPDATA_ALL);
     $obData->setSharedParams($this->_object->detail()->getFieldNameWithName());
     $diagrams = array();
     foreach ($this->_object->getValues() as $obValue) {
         if (isNull($obDiagram = M('Diagram')->loadDiagramByName($this->getDiagramName($obValue)))) {
             $obData->hideColumns(REPDATA_ALL);
             $obData->showColumns($obValue->getVarname());
             $obDiagram = $this->advancedKpiStrategy()->createDiagramByData($obData, $obValue);
             $obDiagram->setPermissionLikeObject($this->_object);
             $obDiagram->rowCaptionVariable($this->_object->detail()->getFieldNameWithName());
             $obDiagram->yLabelsCallbackFunction(array($obValue, 'callbackForPlotAxis'));
             $obDiagram->xLabelsCallbackFunction(array($this->_object->period(), 'getCaptionBySystemValue'));
             $obDiagram->prepareFunction(array($obValue, 'callbackForPlot'));
             $obDiagram->setAxisCaption(array($obValue, 'getAxisCaption'));
             $obDiagram->draw();
             $obDiagram->save();
         }
         $diagrams[] = $obDiagram;
     }
     return $diagrams;
 }
Esempio n. 12
0
 public function getUserString($obUser, $description = 'user')
 {
     $add_str = " (";
     $add_str .= !isNull($obUser->getCity()) ? $obUser->getCity()->name : "Unknown City";
     $add_str .= ")";
     return $description . "=" . $obUser->id() . " " . $obUser->getAddressTo() . $add_str;
 }
Esempio n. 13
0
/**
 * install template type
 * @param string name	: template type name
 * @param string description	: description for template type
 * @param array	variables	: type variables with description
 * 		Example:
 *					  	array(
 *											"nick"			=> "User nick",
 *											"email"			=> "User email (use as login)",
 *											"password"	=> "User password",
 *											"login"			=> "User login",
 *										);
 * @param array templates :	array of templates params
 * 		Example:
 *	 	 	$ar = array();
 *
 *	 	 	$ar[] = array(
 *				"lang"		=> "rus",
 *				"file_path" => "/rus/user/",
 *				"file_name" => "new.php",
 *			);
 *
 *			$ar[] = array(
 *				"lang"		=> "eng",
 *				"file_path" => "/eng/user/",
 *				"file_name" => "new.php",
 *			);
 *
 *
 * @return	void
 */
function installTemplateType($name, $description, array $variables, array $templates)
{
    if (!isNull($obType = M("MailTemplate")->loadTypeById($name))) {
        $obType->delete();
    }
    $obType = M("MailTemplate")->createType($name);
    $obType->description = $description;
    $obType->save();
    if (!isNull($obType)) {
        foreach ($variables as $k => $v) {
            // create variable object
            $ob = $obType->createVariable($k);
            // init variable properties
            $ob->description = $v;
            // save variable
            if (!$ob->save()) {
                print_r($ob->validator()->getErrors());
            }
        }
    }
    if (!isNull($obType)) {
        foreach ($templates as $v) {
            // create template object
            $ob = $obType->createTemplate();
            // init template object properties
            foreach ($v as $k => $s) {
                $ob->{$k} = $s;
            }
            // save template object
            if (!$ob->save()) {
                print_r($ob->validator()->getErrors());
            }
        }
    }
}
Esempio n. 14
0
 public static function getInstance()
 {
     if (isNull(static::$instance)) {
         static::$instance = new static();
     }
     return static::$instance;
 }
 protected function validateContainerName($container)
 {
     if (isNull($this->helper)) {
         $this->helper = new ContainerHelper();
     }
     return $this->helper->containerExists($container);
 }
Esempio n. 16
0
 /**
  * Returns user's account by user id
  *
  * @param 	int $userId
  * @return	RM_Points_Account
  */
 public function getAccount($userId)
 {
     if (isNull($obUser = M('User')->loadUserById($userId))) {
         throw new RM_Base_Exception_Internal("Unable to load user by id: `{$userId}'");
     }
     return $this->_mapper->loadAccountByUserOrCreate($obUser);
 }
Esempio n. 17
0
 public function addFlavoursToBarcode(RM_Barcode_Object $obBarcode, $flavour_names, $flavour_type, &$error)
 {
     $result = FALSE;
     if ($flavour_names) {
         if (!in_array($flavour_type, M('Gpc')->flavour_types())) {
             $error = 'gpc.wrong_flavour_type';
         } else {
             foreach ($obBarcode->getFlavours() as $obFlavour) {
                 $obFlavour->removeBarcode($obBarcode, $flavour_type);
             }
             foreach ($flavour_names as $flavour_name) {
                 if (!trim($flavour_name)) {
                     continue;
                 }
                 if (isNull($obFlavour = M('Gpc')->loadFlavourByName(trim($flavour_name)))) {
                     $error = 'gpc.no_such_flavours';
                 } else {
                     $obFlavour->addBarcode($obBarcode, $flavour_type);
                     $result = TRUE;
                 }
             }
         }
     }
     return $result;
 }
Esempio n. 18
0
 /**
  * Returns admin note object
  *
  * @param 	array					data
  * @param 	RM_Account_iUser		obWriter
  * @return 	RM_AdminNote_Object
  */
 public function createNote($data = array(), RM_Account_iUser $obWriter)
 {
     if (!@$data['type'] && !@$data['type_no_action'] && !@$data['body']) {
         $res = new RM_Base_Result();
         $res->error('at_least_one_field');
         throw new RM_Validator_Exception($res);
     }
     if (isNull($obUser = M('User')->loadUserById(@$data['user_id']))) {
         $res = new RM_Base_Result();
         $res->error('no_such_user');
         throw new RM_Validator_Exception($res);
     }
     $arr = array();
     $arr['writer_id'] = $obWriter->id();
     $arr['user_id'] = $obUser->id();
     if (@$data['type']) {
         $arr['type'] = (int) $data['type'];
     }
     if (@$data['type_no_action']) {
         $arr['type_no_action'] = (int) $data['type_no_action'];
     }
     if (@$data['body']) {
         $arr['body'] = $data['body'];
     }
     //$arr['is_done'] = 1;
     $arr['posted'] = M('Tools')->date()->dbDateTime();
     return $this->_mapper->_storage('adminNote')->createObject($arr);
 }
Esempio n. 19
0
 /**
  * Returns shop
  *
  * @return	RM_Shop_Object
  */
 protected function object()
 {
     if (isNull($this->_shop)) {
         $this->_shop = $this->_mapper->loadShopById($this->shop_id);
     }
     return $this->_shop;
 }
Esempio n. 20
0
 /**
  * Enter description here...
  *
  * @return RM_Db_Query
  */
 protected function _reportQuery()
 {
     if (isNull($this->_query)) {
         $this->_query = $query;
     }
     return $this->_query;
 }
Esempio n. 21
0
 /**
  *	Description...
  *
  *	@return void
  **/
 public function graph()
 {
     if (isNull($this->_graph)) {
         $this->_graph = $this->_plot->graph();
     }
     return $this->_graph;
 }
Esempio n. 22
0
 protected function _composite()
 {
     if (isNull($this->_composite)) {
         $this->_composite = M('ReportScript')->createCompositeCommand();
     }
     return $this->_composite;
 }
Esempio n. 23
0
 /**
  * Enter description here...
  *
  * @param 	string 	$name
  * @return 	RM_Holder_Invoice_Item_State
  */
 protected function _state($name = NULL, $data = array())
 {
     if (!isNull($name) || isNull($this->_state)) {
         $class = 'RM_Holder_Invoice_Item_State_' . ucfirst(isNull($name) ? $this->invoice_state : $name);
         $this->_state = new $class($this, $data);
     }
     return $this->_state;
 }
Esempio n. 24
0
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull(iterFirst(M('Category')->getCategoryList()->filter('name=? and id!=?', $data[$field], $data['id'])))) {
         $result->error('name_not_unique', $field);
         return FALSE;
     }
     return TRUE;
 }
Esempio n. 25
0
 /**
  *	Description...
  *
  *	@return void
  **/
 public function valueSelected($name)
 {
     #!! Need to be refactored!
     if (isNull($obValue = M('ReportValue')->loadObjectByName($name)) || isNull($this->getCompanyGroup())) {
         return FALSE;
     }
     return $obValue->checkGroupPermission($this->getCompanyGroup());
 }
Esempio n. 26
0
 /**
  * Check Email not exists in ssp registration (AuthServer)
  *
  * @param      array			$data               Array with values
  * @param      string     $field          Field to check
  * @param      RM_Base_iResult          Errors and warnngs stack
  * @return     void
  */
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull($company = M('Client')->loadCompanyByName($data[$field])) && $company->id() != $data['id']) {
         $result->error('company_name_unique', $field);
         return false;
     }
     return true;
 }
Esempio n. 27
0
 /**
  * Check Email not exists in ssp registration (AuthServer)
  *
  * @param      array			$data               Array with values
  * @param      string     $field          Field to check
  * @param      RM_Base_iResult          Errors and warnngs stack
  * @return     void
  */
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull($user = M('Client')->loadUserBySslNumber($data[$field])) && $user->id() != $data['id']) {
         $result->error('client_ssl_unique', $field);
         return false;
     }
     return true;
 }
Esempio n. 28
0
 /**
  * Check Email not exists in SSP
  *
  * @param		array		$data		Array with values
  * @param		string		$field		Field to check
  * @param		RM_Base_iResult			Errors and warnngs stack
  * @return		void
  */
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull(M('User')->loadUserByLogin($data[$field]))) {
         $result->error('email_unique', $field);
         return false;
     }
     return true;
 }
Esempio n. 29
0
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (!isNull($script = M('ReportScript')->loadScriptByName($data[$field])) && $script->id() != $data['id']) {
         $result->error('script_name_not_unique', $field);
         return FALSE;
     }
     return TRUE;
 }
Esempio n. 30
0
 public function process(array $data, $field, RM_Base_iResult $result)
 {
     if (isNull($obReceipt = M('Purchase')->receipt()->loadVirtualById($data['id'])) || count($obReceipt->getPurchases())) {
         $result->error('delete_not_empty_receipt', $field);
         return FALSE;
     }
     return TRUE;
 }