示例#1
0
 /**
  * Init function to set up form elements.
  *
  * @return void
  */
 public function init()
 {
     $this->setAttrib('id', 'client-document-form');
     $clients = Repo_Client::getInstance()->getSelectArray();
     // Name
     $this->addElement('text', 'name', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Name', 'required' => true));
     // Client
     $this->addElement('select', 'client', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Client', 'required' => true));
     $this->getElement('client')->addMultiOptions($clients);
     // Description
     $this->addElement('textarea', 'description', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Description', 'rows' => 5));
     // Uploaded file
     $this->addElement('text', 'filepath', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Uploaded File'));
     // Set page values if a page is passed in.
     if (isset($this->extraParams['object']) && ($object = $this->extraParams['object'])) {
         $this->setObject($object);
     }
 }
示例#2
0
 /**
  * Init function to set up form elements.
  *
  * @return void
  */
 public function init()
 {
     $this->setAttrib('id', 'client-media-asset-form');
     $clients = Repo_Client::getInstance()->getSelectArray();
     // Name
     $this->addElement('text', 'name', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Name', 'required' => true));
     // Client
     $this->addElement('select', 'client', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Client', 'required' => true));
     $this->getElement('client')->addMultiOptions($clients);
     // Description
     $this->addElement('textarea', 'description', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Description', 'rows' => 3));
     // Uploaded file
     $this->addElement('text', 'filepath', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Uploaded File', 'description' => '<div id="filepath-image-preview"></div>'));
     // Tags
     $this->addElement('text', 'tag', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Tags', 'ng-model' => 'tagSelected', 'typeahead' => 'tag for tag in getTags($viewValue)', 'typeahead-loading' => 'loadingTags', 'typeahead-on-select' => 'addTag($item, $model, $label)', 'description' => '<i ng-show="loadingTags" class="glyphicon glyphicon-refresh"></i><div><span class="label label-info tag-item" ng-repeat="mediaTag in mediaTags">{{mediaTag.name}} <span class="glyphicon glyphicon-remove" ng-click="removeTag(mediaTag.name)"></span></li></ul>'));
     // Set page values if a page is passed in.
     if (isset($this->extraParams['object']) && ($object = $this->extraParams['object'])) {
         $this->setObject($object);
     }
 }
示例#3
0
 /**
  * Init function to set up form elements.
  *
  * @return void
  */
 public function init()
 {
     $this->setAttrib('id', 'create-new-client-form');
     $clientTypes = Repo_ClientType::getInstance()->getSelectArray();
     $clientTree = Repo_Client::getInstance()->getClientTree();
     // Build up the flat option array
     Functions_Common::$tempCache = array();
     Functions_Common::flattenOptionTree($clientTree, Functions_Common::$tempCache, 'id', 'name', 'children', '');
     $clientTreeOptions = array(' ' => ' ') + Functions_Common::$tempCache;
     // Name
     $this->addElement('text', 'client_name', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Client Name', 'required' => true));
     // Parent
     $this->addElement('select', 'client_parent', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Parent Client', 'required' => false));
     $this->getElement('client_parent')->addMultiOptions($clientTreeOptions);
     // Type
     $this->addElement('select', 'client_type', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Type', 'required' => false));
     $this->getElement('client_type')->addMultiOptions($clientTypes);
     // ID
     $this->addElement('hidden', 'client_id', array('decorators' => $this->_buttonElementDecorator, 'required' => false));
 }
示例#4
0
 /**
  * Get a list of resources based on client id, resource type and resource repo class.
  *
  * @param integer $clientId
  * @param string $resourceType
  * @param string $resourceRepoClass
  * @return array
  */
 public function getClientResources($clientId, $resourceType, $resourceRepoClass, $status)
 {
     if ($clientId) {
         $parentClientIds = Repo_Client::getInstance()->getParentClients($clientId);
         $clientIds = $parentClientIds;
         $clientIds[] = $clientId;
     } else {
         $clientIds = array();
     }
     // Get all the resources
     $resources = $resourceRepoClass::getInstance()->getClientsResources($clientIds, $status);
     // Get all the access rows
     $accessRows = Repo_ResourceAccess::getInstance()->getClientResources($clientId, $resourceType);
     $allowedResources = array();
     // Filter out those not allowed for this client
     foreach ($resources as $_r) {
         if (!$clientId || $_r->client_id == $clientId || in_array($_r->client_id, $accessRows)) {
             $allowedResources[] = $_r;
         }
     }
     return $allowedResources;
 }
示例#5
0
 /**
  * Init function to set up form elements.
  *
  * @return void
  */
 public function init()
 {
     $this->setAttrib('id', 'create-new-user-form');
     $clients = Repo_Client::getInstance()->getSelectArray();
     $roles = Repo_Role::getInstance()->getSelectArray();
     unset($roles['']);
     // Email
     $this->addElement('text', 'email', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Email', 'required' => true, 'validators' => array('EmailAddress')));
     // Password
     $this->addElement('text', 'password', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Password', 'required' => true, 'validators' => array(array('StringLength', false, array(8, 50)))));
     // UDID
     $this->addElement('text', 'UDID', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'UDID', 'required' => false));
     // Surname
     $this->addElement('text', 'surname', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Surname', 'required' => true));
     // First name
     $this->addElement('text', 'firstname', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'First Name', 'required' => true));
     // User type
     /*$this->addElement('text','user_type',array(
           'decorators' => $this->_standardElementDecorator,
           'class' => 'form-control',
           'label' => 'User Type',
           'required' => true
       ));*/
     // Role
     $this->addElement('multiCheckbox', 'role', array('decorators' => $this->_multiCheckboxDecorator, 'label' => 'Role', 'required' => true, 'registerInArrayValidator' => false));
     $this->getElement('role')->addMultiOptions($roles);
     // Client
     $this->addElement('select', 'client', array('decorators' => $this->_standardElementDecorator, 'class' => 'form-control', 'label' => 'Client', 'required' => true));
     $this->getElement('client')->addMultiOptions($clients);
     // ID
     $this->addElement('hidden', 'id', array('decorators' => $this->_buttonElementDecorator, 'required' => false));
     // Set user values if a user is passed in.
     if (isset($this->extraParams['user']) && ($user = $this->extraParams['user'])) {
         $this->setUser($user);
     }
 }
示例#6
0
 /**
  * Get the users from the client and all the parent clients.
  *
  * @param integer $clientId
  * @param Zend_Db_Table_Rowset_Abstract
  */
 public function getClientAndParentClientsUsers($clientId)
 {
     $dbTable = $this->getFetchTable();
     $select = $dbTable->select()->setIntegrityCheck(false)->from(array('u' => 'user'), array('id' => 'u.id', 'name' => "CONCAT_WS(',', u.surname, u.firstname)", 'firstname' => 'u.firstname', 'surname' => 'u.surname', 'email' => 'u.email', 'role_id' => 'u.role_id', 'client_id' => 'u.client_id', 'u.created_datetime', 'u.modified_datetime'))->joinLeft(array('c' => 'client'), 'u.client_id = c.id', array('client_name' => 'c.name'))->joinLeft(array('r' => 'role'), 'u.role_id = r.id', array('user_type' => 'r.label'));
     if ($clientId) {
         $parentClientIds = Repo_Client::getInstance()->getParentClients($clientId);
         $parentClientIds[] = $clientId;
         $select->where('u.client_id IN (' . implode(',', $parentClientIds) . ')');
     }
     $select->where('u.user_type IS NULL OR u.user_type <> ?', self::SERVICE_USER_TYPE);
     $select->order(array('name ASC'));
     return $dbTable->fetchAll($select);
 }
 public function innerSurveyFunction($data, $ratingSign, $start_date, $end_date)
 {
     $user = Zend_Auth::getInstance()->getIdentity();
     // Grab all the clients who have the client_id of the logged in user as parent
     $clients = Repo_Client::getInstance()->getRows("parent_id=" . $user->client_id)->toArray();
     $allClients = array();
     foreach ($clients as $cli) {
         $allClients[] = $cli['id'];
     }
     // Now we should add the client id of the logged in user as well - to that client list.
     $allClients[] = $user->client_id;
     $result = Repo_Watson_Collection_test::getInstance()->findDocument(array("evidencelist.title" => new MongoRegex("/" . $data . "/gi"), "survey" => array('$exists' => true, '$elemMatch' => array("rating" => $ratingSign, "client_id" => $user->client_id)), "query_date" => array('$gte' => new MongoDate((int) $start_date, 0), '$lte' => new MongoDate((int) $end_date, 0))));
     $allQuestions = array();
     foreach ($result as $res) {
         foreach ($res['survey'] as $surv) {
             if ($surv['rating'] == $ratingSign) {
                 foreach ($surv['survey_question'] as $ques) {
                     foreach ($ques as $q) {
                         $allQuestions[] = $q;
                     }
                 }
             }
         }
     }
     $data = array();
     $sql = "";
     if (!empty($allQuestions)) {
         $dbTable = new Db_Table_Abstract();
         $adapter = $dbTable->getDefaultAdapter();
         $sql = "select question.id as question_id," . "survey.id as survey_id," . "survey.name as survey_name," . "question," . "`option`," . "question_option.type_id," . "data," . "client.id,count(data) as sum_of_all from question " . "left join question_option on question.id = question_option.question_id " . "left join user_survey_question on question.id = user_survey_question.question_id " . "left join survey on survey.id = question.survey_id " . "left join client on client.id = survey.client_id " . "where survey.type_id in (select id from survey_type where description = 'watson_survey') " . "and user_survey_question.id in (" . implode(",", array_unique($allQuestions)) . ")" . "and client.id in (" . implode(",", array_unique($allClients)) . ") " . "and completed_datetime between '" . strftime("%Y-%m-%d %H:%M:%S", $start_date) . "' and '" . strftime("%Y-%m-%d %H:%M:%S", $end_date) . "' " . "and user_survey_question.useranswer = question_option.id " . "group by data,question order by survey_name;";
         $data[] = $adapter->fetchAll($sql);
     }
     return array_pop($data);
 }