Пример #1
0
 public function save(Application_Model_Tag $tag)
 {
     //For debugging
     $this->_logger = new Zend_Log();
     $writer = new Zend_Log_Writer_Stream('sample.log');
     $this->_logger->addWriter($writer);
     $this->_logger->log('here2', Zend_Log::INFO);
     $data = array('tag' => $tag->getTag(), 'idea_id' => $tag->getIdeaId());
     if (null === ($id = $tag->getId())) {
         unset($data['tag_id']);
         return $this->getDbTable()->insert($data);
     } else {
         return $this->getDbTable()->update($data, array('tag_id = ?' => $id));
     }
 }
Пример #2
0
 public function fetchRecord($text, $search_type, $is_partial)
 {
     //For debugging
     $this->_logger = new Zend_Log();
     $writer = new Zend_Log_Writer_Stream('sample.log');
     $this->_logger->addWriter($writer);
     //Array to hold the final search results
     $entries = array();
     //Search by destination name
     //Formulate SQL query for partial or full search
     if ($search_type == "Destination") {
         $select = $this->getDbTable()->select();
         if ($is_partial == "true") {
             $filteredText = "%" . $text . "%";
             $select->where('destination like ?', $filteredText);
             $this->_logger->log($select, Zend_Log::INFO);
         } else {
             $select->where('destination = ?', $text);
             $this->_logger->log($select, Zend_Log::INFO);
         }
         $resultSet = $this->getDbTable()->fetchAll($select);
     } else {
         if ($search_type == "Tags") {
             //Access tag's mapper function
             $tagMapper = new Application_Model_TagMapper();
             $selectTag = $tagMapper->getDbTable()->select();
             $selectTag->where('tag = ?', $text);
             $this->_logger->log($selectTag, Zend_Log::INFO);
             $tagResultSet = $tagMapper->getDbTable()->fetchAll($selectTag);
             //Array to store matching ideas object
             $temp_entries = array();
             //Parse return results
             foreach ($tagResultSet as $row) {
                 $entry = new Application_Model_Tag();
                 $entry->setTag($row->tag)->setIdeaId($row->idea_id)->setCreateDatetime($row->create_datetime)->setLastUpdateDatetime($row->last_update_datetime);
                 //Retrive ideas object by idea_id which has a matching tag
                 $select = $this->getDbTable()->select();
                 $select->where('idea_id = ?', $row->idea_id);
                 $tempResultSet = $this->getDbTable()->fetchRow($select);
                 //Aggregate the matching ideas to the same array
                 array_push($temp_entries, $tempResultSet);
             }
             //Assign result for parsing
             $resultSet = $temp_entries;
         }
     }
     //Parse return results
     foreach ($resultSet as $row) {
         $author = new Application_Model_Member();
         $author->setId($row->author_id);
         $entry = new Application_Model_Idea();
         $entry->setId($row->idea_id)->setDestination($row->destination)->setTitle($row->title)->setStartDate($row->start_date)->setEndDate($row->end_date)->setAuthor($row->author)->setCreateDatetime($row->create_datetime)->setLastUpdateDatetime($row->last_update_datetime);
         $entries[] = $entry;
     }
     return $entries;
 }
Пример #3
0
 public function viewAction()
 {
     $project_id = $this->_getParam('id');
     $this->view->selected_tab = $this->_getParam("tab");
     //PROJECT DATA
     $projectInfo = Application_Model_Projects::GetProjectInfo($project_id);
     if (!$projectInfo->project_id) {
         ProNav_Auth::unauthorized();
     }
     $this->view->open_projects = Application_Model_Projects::OpenProjectsCountAtLocation($projectInfo->done_at_location, $project_id);
     $this->view->active_projects = Application_Model_Projects::ActiveProjectsCountAtLocation($projectInfo->done_at_location, $project_id);
     $this->view->project_id = $projectInfo->project_id;
     $this->view->projectinfo = $projectInfo;
     $executed_cors = array();
     $cors = Application_Model_ChangeOrders::getRequestsForProject($project_id, true, true);
     foreach ($cors as $cor) {
         if ($cor->accounting_stage_id == Application_Model_ChangeOrderRequest::ACCT_EXECUTED) {
             $executed_cors[] = $cor;
         }
     }
     //Overview
     $this->view->general_info = $this->view->partial('project/partial-general-info.phtml', array('projectinfo' => $projectInfo, 'open_projects' => $this->view->open_projects, 'active_projects' => $this->view->active_projects));
     //Project Value
     if (!ProNav_Auth::isEmployee() || ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_VALUE_VIEW)) {
         $this->view->project_value = $this->view->partial('project/partial-project-value.phtml', array('base_project' => $projectInfo, 'original_contract_value' => $projectInfo->getProjectValue(), 'has_executed_cos' => count($executed_cors), 'executed_cos_value' => Application_Model_ChangeOrders::sumProjectValue($executed_cors), 'total_contract_value' => Application_Model_ChangeOrders::sumProjectValue($executed_cors, $projectInfo)));
     }
     //Material Location
     $this->view->material = $this->view->partial('project/material-location.phtml', array('projectinfo' => $projectInfo));
     //Scope of Work
     if (!ProNav_Auth::isEmployee() || ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_SCOPE_VIEW)) {
         $this->view->scope = $this->view->partial('project/scope.phtml', array('projectinfo' => $projectInfo));
     }
     //Accounting
     if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_ACCOUNTING_VIEW)) {
         $this->view->accounting = $this->view->partial('project/accounting.phtml', array('projectinfo' => $projectInfo));
     }
     //Work Acquisition/Sales
     if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_SALES_VIEW)) {
         $this->view->work_acquisition = $this->view->partial('project/acquisition.phtml', array('project' => $projectInfo));
     }
     //Tags
     if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_TAGS_GENERAL_ACCESS)) {
         $this->view->tagSelections = Application_Model_Tag::getTagsFor(Application_Model_Tag::OBJ_PROJECT, $project_id);
     }
     //Stage History
     if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_HISTORY_VIEW)) {
         $this->view->stagehistory = $this->view->partial('project/partial-stage-history.phtml', array('stagehistory' => Application_Model_Projects::getStageHistory($project_id)));
     }
     //Change Order Requests
     if (!ProNav_Auth::isEmployee() || ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_CHANGE_ORDER_VIEW)) {
         $this->view->cors = $this->view->partial('change-order/partial-request-table.phtml', array('projectInfo' => $projectInfo, 'cors' => $cors));
     }
     //Project Notes
     if (!ProNav_Auth::isEmployee() || ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_NOTES_VIEW)) {
         $this->view->project_notes = $this->getNotesModule($projectInfo->project_id);
     }
     //Customer Notes
     if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_CUSTOMER_NOTES)) {
         $this->view->customerNotes = Application_Model_Notes::getProjectRelevantNotes($projectInfo);
         $this->view->customerNotesTable = $this->view->partial('note/note-entity-project-stack.phtml', array('customerNotes' => $this->view->customerNotes, 'projectInfo' => $projectInfo));
     }
     //FILES
     if (!ProNav_Auth::isEmployee() || ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_FILES_VIEW_TAB)) {
         $rootFolder = Application_Model_FileFolders::getFolder(Application_Model_File::OBJ_PROJECT, $project_id, null, true);
         $this->view->files = $this->view->partial('file/partial-file-module.phtml', array('folder' => $rootFolder, 'obj_type' => Application_Model_File::OBJ_PROJECT, 'obj_id' => $project_id));
     }
     if (!ProNav_Auth::isEmployee() || ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_PROGRESS_VIEW_TAB)) {
         //Progress
         //Items only relevant once the project has reached an open status
         /*
         if ($projectInfo->isSecured()){
         $this->view->status = $this->view->partial('project/status.phtml',array('projectinfo'=>$projectInfo));
         }
         */
         //Project Tasks
         $this->view->project_tasks = $this->view->partial('project-tasks/view.phtml', array('task_groups' => Application_Model_ProjectTask::get_tasks_by_project_id($project_id), 'projectinfo' => $projectInfo, 'progress_options' => Application_Model_ProgressOptions::get(true, true)));
         //Punch Lists
         /*
         $this->view->project_punch_list = $this->view->partial('project-punch-list/view.phtml', array(
             'punch_list' => Application_Model_ProjectPunchList::get_items_by_project_id($project_id)
         
         ));
         */
         //Project Labor
         if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_LABOR_PROD_VIEW)) {
             $this->view->project_labor = $this->view->partial('project-labor/view.phtml', array('labor' => Application_Model_ProjectLabor::getLaborSummary($project_id)));
         }
         //Post Project Analysis (PPA)
         if ($projectInfo->isStatus100Percent() && ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_PPA_VIEW)) {
             $this->view->project_analysis = $this->view->partial('project-analysis/view.phtml', array('project_id' => $project_id, 'analysis' => Application_Model_ProjectAnalysisType::get_work_types_for_project($project_id)));
         }
     }
     //RFIS
     if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_RFI_VIEW)) {
         $rfis = Application_Model_RFIs::getRFIsForProject($project_id);
         $this->view->rfis = $this->view->partial('project/partial-rfis.phtml', array('rfis' => $rfis));
     }
     //Submittals
     if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_SUBMITTAL_VIEW)) {
         $submittals = Application_Model_Submittals::getSubmittalsForProject($project_id);
         $this->view->submittals = $this->view->partial('project/partial-submittals.phtml', array('submittals' => $submittals));
     }
     //Job Journals
     //since there can be hundreds of journals, don't get a deeply-populated array like rfis and submittals
     if (ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_JOURNAL_VIEW)) {
         $journal_log = Application_Model_Journals::getJournalsLog($project_id);
         $this->view->journals = $this->view->partial('project/partial-journals.phtml', array('journals' => $journal_log, 'project_id' => $project_id));
         $this->view->has_incomplete_journal = Application_Model_Journals::userHasIncomplete($journal_log);
     }
     //Project Team
     if (!ProNav_Auth::isEmployee() || ProNav_Auth::hasPerm(ProNav_Auth::PERM_PROJECTS_TEAM_VIEW)) {
         $projectTeam = Application_Model_Projects::getProjectTeam($project_id);
         $this->view->project_team = $this->view->partial('project/project-team.phtml', array('users' => $projectTeam));
         $this->view->userIsOnTeam = array_key_exists(ProNav_Auth::getUserID(), $projectTeam);
     }
     //Schedule
     //$this->view->schedule = $this->view->partial('project/schedule.phtml',array('projectinfo'=> $projectInfo));
 }
Пример #4
0
 public function editAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam("id");
     // Get the idea information from the database
     $form = new Application_Form_Idea();
     $mapper = new Application_Model_IdeaMapper();
     $idea = new Application_Model_Idea();
     $mapper->find($id, $idea);
     // Get the tag information from the database
     $mapper = new Application_Model_TagMapper();
     $tags = $mapper->fetchByIdea($idea);
     // formulate the tag string for the idea
     $tagString = "";
     foreach ($tags as $tag) {
         $tagString = $tagString . $tag->getTag() . ";";
     }
     $idea->setTagString($tagString);
     //handle changes to travel idea
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             //get the newly updated form value
             $idea = new Application_Model_Idea($form->getValues());
             //set the id of the idea in order to make changes to the same idea in database
             $idea->setId($id);
             // Get idea author information
             $author = new Application_Model_Member();
             $authns = new Zend_Session_Namespace('AuthNameSpace');
             $mapper = new Application_Model_MemberMapper();
             $mapper->find($authns->userId, $author);
             $idea->setAuthor($author);
             // save the idea in the database
             $mapper = new Application_Model_IdeaMapper();
             $mapper->save($idea);
             // Delete all the tag related to this idea
             $mapper = new Application_Model_TagMapper();
             $mapper->deleteByIdeaId($id);
             $this->_logger->log('after update idea, tag String =' . $idea->tagString, Zend_Log::INFO);
             // Extract the updated tag
             $tags = explode(";", $idea->tagString);
             foreach ($tags as $temp) {
                 if (strlen($temp) > 0) {
                     $tag = new Application_Model_Tag();
                     $tag->setTag($temp);
                     $tag->setIdeaId($id);
                     $this->_logger->log('tag = ' . $temp, Zend_Log::INFO);
                     // Save the tag in the database
                     $mapper->save($tag);
                 }
             }
             $this->_helper->FlashMessenger()->setNamespace('success')->addMessage('Update Successful!');
             $this->_logger->log('Update Idea successfully! ID =' . $id, Zend_Log::INFO);
             $this->_redirector->gotoSimple('detail', 'ideas', null, array('id' => $id));
             return;
         }
     }
     //form data array to populate idea creation form with existing data
     $data = array('title' => $idea->getTitle(), 'destination' => $idea->getDestination(), 'startDate' => $idea->getStartDate(), 'endDate' => $idea->getEndDate(), 'tagString' => $idea->getTagString());
     $form->populate($data);
     $this->view->form = $form;
 }