Inheritance: extends Editable
Example #1
0
 /**
  * Load customer log data by customer id
  *
  * @param int $customerId
  * @return array
  */
 protected function loadLogData($customerId)
 {
     /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */
     $connection = $this->resource->getConnection();
     $select = $connection->select()->from(['cl' => $this->resource->getTableName('customer_log')])->joinLeft(['cv' => $this->resource->getTableName('customer_visitor')], 'cv.customer_id = cl.customer_id', ['last_visit_at'])->where('cl.customer_id = ?', $customerId)->order('cv.visitor_id DESC')->limit(1);
     return $connection->fetchRow($select);
 }
Example #2
0
 function clearUserRating()
 {
     global $user;
     $source = $_REQUEST['source'];
     $recordId = $_REQUEST['recordId'];
     $result = array('result' => false);
     if ($source == 'VuFind') {
         require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php';
         $resource = new Resource();
         $resource->record_id = $recordId;
         $resource->source = 'VuFind';
         if ($resource->find(true)) {
             $rating = new UserRating();
             $rating->userid = $user->id;
             $rating->resourceid = $resource->id;
             if ($rating->find(true)) {
                 if ($rating->delete()) {
                     $result = array('result' => true, 'message' => 'deleted user rating for resource ' . $rating->resourceid);
                 }
             }
         }
     } else {
         require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
         $econtentRating = new EContentRating();
         $econtentRating->userId = $user->id;
         $econtentRating->recordId = $recordId;
         if ($econtentRating->find(true)) {
             if ($econtentRating->delete()) {
                 $result = array('result' => true);
             }
         }
     }
     return json_encode($result);
 }
Example #3
0
 /** @test **/
 public function it_can_have_multiple_attributes()
 {
     $mockBuilder = $this->getMockBuilder(Attribute::class)->disableOriginalConstructor();
     $attributes = [$mockBuilder->getMock(), $mockBuilder->getMock()];
     array_walk($attributes, [$this->resource, 'addAttribute']);
     $this->assertEquals($attributes, $this->resource->getAttributes());
 }
 public function testRefreshSpecialPrices()
 {
     $idsToProcess = [1, 2, 3];
     $this->metadataPool->expects($this->atLeastOnce())->method('getMetadata')->willReturn($this->metadataMock);
     $this->metadataMock->expects($this->atLeastOnce())->method('getLinkField')->willReturn('row_id');
     $this->metadataMock->expects($this->atLeastOnce())->method('getIdentifierField')->willReturn('entity_id');
     $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $selectMock->expects($this->any())->method('from')->will($this->returnSelf());
     $selectMock->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $selectMock->expects($this->any())->method('where')->will($this->returnSelf());
     $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false);
     $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock));
     $connectionMock->expects($this->any())->method('fetchCol')->will($this->returnValue($idsToProcess));
     $this->_resourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($connectionMock));
     $this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnValue('category'));
     $storeMock = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false);
     $storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->_storeManagerMock->expects($this->once())->method('getStores')->with(true)->will($this->returnValue([$storeMock]));
     $this->_localeDateMock->expects($this->once())->method('scopeTimeStamp')->with($storeMock)->will($this->returnValue(32000));
     $indexerMock = $this->getMock('Magento\\Indexer\\Model\\Indexer', [], [], '', false);
     $indexerMock->expects($this->exactly(2))->method('reindexList');
     $this->_priceProcessorMock->expects($this->exactly(2))->method('getIndexer')->will($this->returnValue($indexerMock));
     $attributeMock = $this->getMockForAbstractClass('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [], '', false, true, true, ['__wakeup', 'getAttributeId']);
     $attributeMock->expects($this->any())->method('getAttributeId')->will($this->returnValue(1));
     $this->_eavConfigMock->expects($this->any())->method('getAttribute')->will($this->returnValue($attributeMock));
     $this->_model->execute();
 }
Example #5
0
 public function addResource($route, Resource $resource)
 {
     $resource->setRoute($route);
     $resource->setPrefix($this);
     $this->resources[$route] = $resource;
     return $resource;
 }
 public function testResetSearchResult()
 {
     $this->resource->expects($this->once())->method('getTableName')->with('search_query', ResourceConnection::DEFAULT_CONNECTION)->willReturn('table_name_search_query');
     $this->connection->expects($this->once())->method('update')->with('table_name_search_query', ['is_processed' => 0], ['is_processed != 0'])->willReturn(10);
     $result = $this->target->resetSearchResults();
     $this->assertEquals($this->target, $result);
 }
 private function addResource($type, $file_names, $single = false)
 {
     if ($single) {
         if (count($file_names) > 1) {
             $file_names = array($file_names[0]);
         }
         $Resource = new Resource();
         $type == 'file' ? $Resource->setFile($file_names[0]) : $Resource->setString($file_names[0]);
         /*$Resource->setDriver($this->driver);*/
         $this->resources[] = $Resource;
         $Resource->collection = $this;
         return $Resource;
     } else {
         $class = __CLASS__;
         $Collection = new $class();
         $Collection->collection = $this;
         $this->resources[] = $Collection;
         foreach ($file_names as $data) {
             if (is_string($data)) {
                 $type == 'file' ? $Collection->addSingleFile($data) : $Collection->addSingleString($data);
             } else {
                 $type == 'file' ? $Collection->addFile($data) : $Collection->addString($data);
             }
         }
         return $Collection;
     }
 }
Example #8
0
 /**
  * @test
  */
 public function normalCases()
 {
     $this->assertEquals('something id', $this->subject->description());
     $this->assertEquals('sampleId', $this->subject->name());
     $this->assertEquals('string', $this->subject->type());
     $this->assertEquals('path', $this->subject->paramType());
 }
Example #9
0
 function launch()
 {
     global $interface;
     global $configArray;
     $rating = $_REQUEST['rating'];
     $interface->assign('rating', $rating);
     $id = $_REQUEST['id'];
     // Check if user is logged in
     if (!$this->user) {
         // Needed for "back to record" link in view-alt.tpl:
         $interface->assign('id', $id);
         //Display the login form
         $login = $interface->fetch('Record/ajax-rate-login.tpl');
         header('Content-type: text/plain');
         header('Cache-Control: no-cache, must-revalidate');
         // HTTP/1.1
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         echo json_encode(array('result' => 'true', 'loginForm' => $login));
         exit;
     }
     if (isset($_GET['submit'])) {
         global $user;
         //Save the rating
         $resource = new Resource();
         $resource->record_id = $id;
         $resource->source = 'VuFind';
         if (!$resource->find(true)) {
             $resource->insert();
         }
         $resource->addRating($rating, $user);
         return json_encode(array('result' => 'true', 'rating' => $rating));
     }
 }
Example #10
0
 function __construct($relType, Resource $resource)
 {
     $this->setRelType($relType);
     $this->setName($resource->getName());
     $this->setCollectionName($resource->getCollectionName());
     $this->setHref($resource->getHref());
 }
Example #11
0
 public function launch()
 {
     global $interface;
     global $user;
     //Load user ratings
     require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php';
     $rating = new UserRating();
     $resource = new Resource();
     $rating->joinAdd($resource);
     $rating->userid = $user->id;
     $rating->find();
     $ratings = array();
     while ($rating->fetch()) {
         if ($rating->deleted == 0) {
             $ratings[] = array('id' => $rating->id, 'title' => $rating->title, 'author' => $rating->author, 'format' => $rating->format, 'rating' => $rating->rating, 'resourceId' => $rating->resourceid, 'fullId' => $rating->record_id, 'shortId' => $rating->shortId, 'link' => '/Record/' . $rating->record_id . '/Home', 'dateRated' => $rating->dateRated, 'ratingData' => array('user' => $rating->rating), 'source' => 'VuFind');
         }
     }
     //Load econtent ratings
     require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
     $eContentRating = new EContentRating();
     $econtentRecord = new EContentRecord();
     $eContentRating->joinAdd($econtentRecord);
     $eContentRating->userId = $user->id;
     $eContentRating->find();
     while ($eContentRating->fetch()) {
         if ($eContentRating->status == 'active') {
             $resource = new Resource();
             $resource->record_id = $eContentRating->id;
             $resource->source = 'eContent';
             $resource->find(true);
             $ratings[] = array('id' => $eContentRating->id, 'title' => $eContentRating->title, 'author' => $eContentRating->author, 'format' => $resource->format_category, 'rating' => $eContentRating->rating, 'fullId' => $eContentRating->id, 'shortId' => $eContentRating->id, 'link' => '/EcontentRecord/' . $eContentRating->id . '/Home', 'dateRated' => $eContentRating->dateRated, 'ratingData' => array('user' => $eContentRating->rating), 'source' => 'eContent');
         }
     }
     asort($ratings);
     //Load titles the user is not interested in
     $notInterested = array();
     $notInterestedObj = new NotInterested();
     $resource = new Resource();
     $notInterestedObj->joinAdd($resource);
     $notInterestedObj->userId = $user->id;
     $notInterestedObj->deleted = 0;
     $notInterestedObj->selectAdd('user_not_interested.id as user_not_interested_id');
     $notInterestedObj->find();
     while ($notInterestedObj->fetch()) {
         if ($notInterestedObj->source == 'VuFind') {
             $link = '/Record/' . $notInterestedObj->record_id;
         } else {
             $link = '/EcontentRecord/' . $notInterestedObj->record_id;
         }
         if ($notInterestedObj->deleted == 0) {
             $notInterested[] = array('id' => $notInterestedObj->user_not_interested_id, 'title' => $notInterestedObj->title, 'author' => $notInterestedObj->author, 'dateMarked' => $notInterestedObj->dateMarked, 'link' => $link);
         }
     }
     $interface->assign('ratings', $ratings);
     $interface->assign('notInterested', $notInterested);
     $interface->setPageTitle('My Ratings');
     $interface->setTemplate('myRatings.tpl');
     $interface->display('layout.tpl');
 }
Example #12
0
 public function testMostSpecificRuleAppliesIfNoExactRuleIsFound()
 {
     $this->repository->addRule($this->role1, $this->resource1, true);
     $this->repository->addRule($this->role1, $this->resource2, false);
     $rule = $this->repository->getMostApplyingRule($this->role2, $this->resource2);
     $this->assertSame($this->role1->getRoleId(), $rule->getRoleId());
     $this->assertSame($this->resource2->getResourceId(), $rule->getResourceId());
 }
 public function addResource(Resource $resource)
 {
     $className = $resource->getClassName();
     if (true === isset($this->resources[$className])) {
         throw new \InvalidArgumentException(sprintf('Resource for class %s has been added', $className));
     }
     $this->resources[$className] = $resource;
 }
Example #14
0
 /**
  * Check to see if the given Subject is authorized for the given Resource
  *
  * @param Subject $subject Subject making request
  * @param \Xacmlphp\Resource $resource Resource being accessed (policies attached)
  * @param Action $action Action instance
  *
  * @return bool Allowed/not allowed status
  */
 public function isAuthorized(Subject $subject, Resource $resource, Action $action)
 {
     $decider = $this->getDecider();
     if ($decider === null) {
         throw new \InvalidArgumentException('Invalid Decider object');
     }
     $policies = $resource->getPolicies();
     return $decider->evaluate($subject, $policies, $action);
 }
 /**
  * @param array $values
  * @return $this
  */
 public function populate(array $values = [])
 {
     foreach ($values as $value) {
         $resource = new Resource();
         $resource->populate($value);
         $this->resources[] = $resource;
     }
     return $this;
 }
 /**
  * @param string $flatTable
  * @param bool $isFlatTableExists
  * @param string $flatDropName
  * @param string $temporaryFlatTableName
  * @param array $expectedRenameTablesArgument
  * @dataProvider moveDataProvider
  */
 public function testMove($flatTable, $isFlatTableExists, $flatDropName, $temporaryFlatTableName, $expectedRenameTablesArgument)
 {
     $this->_connectionMock->expects($this->exactly(2))->method('dropTable')->with($flatDropName);
     $this->_connectionMock->expects($this->once())->method('isTableExists')->with($flatTable)->will($this->returnValue($isFlatTableExists));
     $this->_connectionMock->expects($this->once())->method('renameTablesBatch')->with($expectedRenameTablesArgument);
     $this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->_connectionMock));
     $model = $this->_objectManager->getObject('Magento\\Catalog\\Model\\Indexer\\Product\\Flat\\TableData', ['resource' => $this->_resourceMock]);
     $model->move($flatTable, $flatDropName, $temporaryFlatTableName);
 }
Example #17
0
 /**
  * @see AbstractController::run()
  */
 public function run(Resource $resource)
 {
     $uriParams = $resource->getParams();
     $formParams = RequestManager::getAllParams();
     $uc = new UserPreferencesController();
     $uc->getUserPreference(Utils::getLoggedInUserId());
     $this->populateProgramData($uriParams, $formParams);
     $this->getView()->setViewName(self::MODULE_KEY)->display();
 }
Example #18
0
 public function run(Resource $resource)
 {
     $uriParams = $resource->getParams();
     $formParams = RequestManager::getAllParams();
     if (!empty($formParams[self::FILE_UPLOAD_ACTION_NAME]) && $formParams[self::FILE_UPLOAD_ACTION_NAME] == self::FILE_UPLOAD_ACTION_VALUE) {
         $this->uploadFile($formParams);
     } else {
         $this->getView()->setViewName(self::MODULE_KEY)->display();
     }
 }
Example #19
0
 public function testManage()
 {
     // Run first time to generate assets
     $this->resource->manage([__DIR__]);
     foreach ($this->files as $file) {
         $this->assertFileExists(ResourceManager::$cacheRoot . dirname($file) . '/' . pathinfo($file, PATHINFO_FILENAME) . '.' . $this->resource->convertType($file));
     }
     // Run second time to use cache
     $this->resource->manage([__DIR__]);
 }
Example #20
0
 /**
  * @see AbstractController::run()
  */
 public function run(Resource $resource)
 {
     $inputParams = $resource->getParams();
     $pid = $inputParams[Constants::INPUT_PARAM_ACTION];
     if (!empty($pid)) {
         $this->downloadFile($pid);
     } else {
         throw new Exception("No File Info Provided!");
     }
 }
Example #21
0
 public function getComposite()
 {
     $composerName = $this->resource->getComposer();
     $composer = $this->composerManager->getComposer($composerName);
     $data = is_object($this->resource->getData()) ? array($this->resource->getData()) : $this->resource->getData();
     // Get embeded composed models
     $embededModels = $composer->getEmbededModels($this, $data);
     // Compose resource
     $embededModels = $embededModels ? $embededModels : array();
     return $composer->compose($data, $embededModels);
 }
 public function run(Resource $resource)
 {
     $uriParams = $resource->getParams();
     $formParams = RequestManager::getAllParams();
     if (strtolower($uriParams[Constants::INPUT_PARAM_ACTION]) === 'save') {
         if ($this->saveUserPreference($formParams)) {
             Response::sendResponse(Constants::SUCCESS_RESPONSE, Messages::SUCCESS_UPDATE);
         } else {
             Response::sendResponse(Constants::SUCCESS_RESPONSE, Messages::ERROR_OPERATION_FAILED);
         }
     }
 }
Example #23
0
 /**
  * Set appropriate parameter for given resource
  * 
  * @param Resource $resource
  * @param array $set
  * @return resource
  */
 private static function setCorrectParams(Resource $resource, array $set)
 {
     $params = array();
     $altkeys = array(Constants::INDEX_URI_KEY, Constants::EXPLORER_URI_KEY);
     if (in_array($resource->getKey(), $altkeys)) {
         $params = array(Constants::INPUT_PARAM_LANG => $set[0], Constants::INPUT_PARAM_CATE => $set[1], Constants::INPUT_PARAM_PID => $set[2]);
     } else {
         $params = array(Constants::INPUT_PARAM_MODULE => $set[0], Constants::INPUT_PARAM_ACTION => $set[1], Constants::INPUT_PARAM_SUBACTION => $set[2]);
     }
     $resource->setParams($params);
     return $resource;
 }
Example #24
0
 /**
  * {@inheritdoc}
  */
 public function getAggregations(\Magento\Framework\Search\Dynamic\EntityStorage $entityStorage)
 {
     $aggregation = ['count' => 'count(DISTINCT main_table.entity_id)', 'max' => 'MAX(min_price)', 'min' => 'MIN(min_price)', 'std' => 'STDDEV_SAMP(min_price)'];
     $select = $this->getSelect();
     $tableName = $this->resource->getTableName('catalog_product_index_price');
     /** @var Table $table */
     $table = $entityStorage->getSource();
     $select->from(['main_table' => $tableName], [])->joinInner(['entities' => $table->getName()], 'main_table.entity_id  = entities.entity_id', [])->columns($aggregation);
     $select = $this->setCustomerGroupId($select);
     $result = $this->connection->fetchRow($select);
     return $result;
 }
Example #25
0
 /**
  * Constructor
  *
  * To save a few keystrokes, the Controller is executed as part of the
  * constructor instead of via a method. You either want the Controller or
  * you don't.
  */
 public function __construct()
 {
     parent::__construct();
     try {
         // Secure by default
         if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == false) {
             throw new \Exception('HTTPS is required.', 400);
         }
         // Grabs the requested page
         $request = $_REQUEST['request'];
         $components = explode('/', $request);
         $nouns = [];
         $uids = [];
         $version = array_shift($components);
         $_SERVER['__version'] = substr($version, 1);
         // Checks if we're trying to rock some OAuth
         if ($components[0] == 'oauth') {
             $class = 'Pickles\\OAuth2\\Resource';
         } else {
             // Loops through the components to determine nouns and IDs
             foreach ($components as $index => $component) {
                 if ($index % 2) {
                     $uids[end($nouns)] = $component;
                 } else {
                     $nouns[] = $component;
                 }
             }
             // Creates our class name
             array_unshift($nouns, '', 'Pickles', 'App', 'Resources', $version);
             $class = implode('\\', $nouns);
         }
         // Checks that the file is present and contains our class
         if (!class_exists($class)) {
             throw new \Exception('Not Found.', 404);
         }
         // Instantiates our resource with the UIDs
         $resource = new $class($uids);
     } catch (\Exception $e) {
         // Creates a resource object if we don't have one
         if (!isset($resource)) {
             $resource = new Resource();
         }
         $code = $e->getCode();
         // Anything below 200 is probably a PHP error
         if ($code < 200) {
             $code = 500;
         }
         $resource->status = $code;
         $resource->message = $e->getMessage();
     }
     $resource->respond();
 }
Example #26
0
 /**
  * Retrieve customer IDs for reindex
  *
  * @return array
  */
 protected function getCustomerIdsForReindex()
 {
     $connection = $this->resource->getConnection();
     $gridTableName = $this->flatScopeResolver->resolve(Customer::CUSTOMER_GRID_INDEXER_ID, []);
     $select = $connection->select()->from($this->resource->getTableName($gridTableName), 'last_visit_at')->order('last_visit_at DESC')->limit(1);
     $lastVisitAt = $connection->query($select)->fetchColumn();
     $select = $connection->select()->from($this->resource->getTableName('customer_log'), 'customer_id')->where('last_login_at > ?', $lastVisitAt);
     $customerIds = [];
     foreach ($connection->query($select)->fetchAll() as $row) {
         $customerIds[] = $row['customer_id'];
     }
     return $customerIds;
 }
Example #27
0
 private static function fromArray($array)
 {
     $resource = new Resource();
     if (isset($array["abstract"]) && $array["abstract"]) {
         $resource->isAbstract();
     }
     foreach ($array as $key => $actionData) {
         if (in_array(strtolower($key), ["get", "post", "put", "delete", "any"])) {
             $resource->on(strtolower($key), $actionData);
         }
     }
     return $resource;
 }
Example #28
0
 /**
  * Get all resources associated with the current tag.
  *
  * @return array
  * @access public
  */
 public function getResources()
 {
     $resList = array();
     $sql = 'SELECT "resource".* FROM "resource_tags", "resource" ' . 'WHERE "resource"."id" = "resource_tags"."resource_id" ' . 'AND "resource_tags"."tag_id" = ' . "'" . $this->escape($this->id) . "'";
     $res = new Resource();
     $res->query($sql);
     if ($res->N) {
         while ($res->fetch()) {
             $resList[] = clone $res;
         }
     }
     return $resList;
 }
Example #29
0
 /**
  * Build index query
  *
  * @param RequestInterface $request
  * @return Select
  */
 public function build(RequestInterface $request)
 {
     $searchIndexTable = $this->scopeResolver->resolve($request->getIndex(), $request->getDimensions());
     $select = $this->resource->getConnection()->select()->from(['search_index' => $searchIndexTable], ['entity_id' => 'entity_id'])->joinLeft(['cea' => $this->resource->getTableName('catalog_eav_attribute')], 'search_index.attribute_id = cea.attribute_id', []);
     $select = $this->tableMapper->addTables($select, $request);
     $select = $this->processDimensions($request, $select);
     $isShowOutOfStock = $this->config->isSetFlag('cataloginventory/options/show_out_of_stock', ScopeInterface::SCOPE_STORE);
     if ($isShowOutOfStock === false) {
         $select->joinLeft(['stock_index' => $this->resource->getTableName('cataloginventory_stock_status')], 'search_index.entity_id = stock_index.product_id' . $this->resource->getConnection()->quoteInto(' AND stock_index.website_id = ?', $this->storeManager->getWebsite()->getId()), []);
         $select->where('stock_index.stock_status = ?', 1);
     }
     return $select;
 }
 /**
  *  Output html form to select a location (place)
  *
  *	@param	string	$selected       Preselected type
  *	@param  string	$htmlname       Name of field in form
  *  @param  string	$filter         Optionnal filters criteras (example: 's.rowid <> x')
  *	@param	int		$showempty		Add an empty field
  * 	@param	int		$showtype		Show third party type in combolist (customer, prospect or supplier)
  * 	@param	int		$forcecombo		Force to use combo box
  *  @param	array	$event			Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
  *  @param	string	$filterkey		Filter on key value
  *  @param	int		$outputmode		0=HTML select string, 1=Array
  *  @param	int		$limit			Limit number of answers
  * 	@return	string					HTML string with
  */
 function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20)
 {
     global $conf, $user, $langs;
     $out = '';
     $outarray = array();
     $resourcestat = new Resource($this->db);
     $resources_used = $resourcestat->fetch_all_used('ASC', 't.rowid', $limit, $offset, $filter = '');
     $out = '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
     $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
     //$out.= '<input type="hidden" name="action" value="search">';
     //$out.= '<input type="hidden" name="id" value="'.$theme->id.'">';
     if ($resourcestat) {
         if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && !$forcecombo) {
             //$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2);
             $out .= ajax_combobox($htmlname, $event, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
         }
         // Construct $out and $outarray
         $out .= '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">' . "\n";
         if ($showempty) {
             $out .= '<option value="-1"></option>' . "\n";
         }
         $num = count($resourcestat->lines);
         //var_dump($resourcestat->lines);
         $i = 0;
         if ($num) {
             while ($i < $num) {
                 $label = $langs->trans(ucfirst($resourcestat->lines[$i]->element)) . ' : ';
                 $label .= $resourcestat->lines[$i]->ref ? $resourcestat->lines[$i]->ref : '' . $resourcestat->lines[$i]->label;
                 if ($selected > 0 && $selected == $resourcestat->lines[$i]->id) {
                     $out .= '<option value="' . $resourcestat->lines[$i]->id . '" selected="selected">' . $label . '</option>';
                 } else {
                     $out .= '<option value="' . $resourcestat->lines[$i]->id . '">' . $label . '</option>';
                 }
                 array_push($outarray, array('key' => $resourcestat->lines[$i]->id, 'value' => $resourcestat->lines[$i]->label, 'label' => $resourcestat->lines[$i]->label));
                 $i++;
                 if ($i % 10 == 0) {
                     $out .= "\n";
                 }
             }
         }
         $out .= '</select>' . "\n";
         $out .= '<input type="submit" class="button" value="' . $langs->trans("Search") . '"> &nbsp; &nbsp; ';
         $out .= '</form>';
     } else {
         dol_print_error($this->db);
     }
     if ($outputmode) {
         return $outarray;
     }
     return $out;
 }