public function indexAction() { $user = za()->getUser(); // If it's an external user, redirect to the external module if ($user->getDefaultModule() != '') { // redirect appropriately $this->redirect('index', null, null, $user->getDefaultModule()); return; } $this->view->items = $this->notificationService->getWatchedItems($user, array('Project', 'Client')); $cats = array(); $start = date('Y-m') . '-01 00:00:00'; $end = date('Y-m-t') . ' 23:59:59'; $order = 'endtime desc'; $startDay = date('Y-m-d') . ' 00:00:00'; $endDay = date('Y-m-d') . ' 23:59:59'; // $this->view->taskInfo = $this->projectService->getTimesheetReport($user, null, null, -1, $start, $end, $cats, $order); // $this->view->dayTasks = $this->projectService->getDetailedTimesheet($user, null, null, null, -1, $startDay, $endDay); $this->view->latest = $this->projectService->getProjects(array('ismilestone=' => 0), 'updated desc', 1, 10); $task = new Task(); $this->view->categories = $task->constraints['category']->getValues(); $this->view->startDate = $start; $this->view->endDate = $end; $this->view->favourites = $this->dbService->getObjects('PanelFavourite', array('creator=' => za()->getUser()->username)); $this->renderView('index/index.php'); }
protected function getChildDataClient(Client $client, $options = null) { $projects = $this->projectService->getProjects(array('clientid=' => $client->id, 'ismilestone=' => 0, 'parentid=' => 0)); $data = array(); foreach ($projects as $project) { $item = new stdClass(); $item->id = get_class($project) . '-' . $project->id; $item->text = $project->title . ' <a href="' . build_url('project', 'view', array('id' => $project->id)) . '"><img src="' . resource('images/bullet_go.png') . '" /></a>'; $item->expanded = false; $item->classes = "project-item iconed"; $item->hasChildren = true; $data[] = $item; } return $data; }
public function clientprojectsAction() { $clientid = (int) $this->_getParam('clientid'); $this->view->projects = $this->projectService->getProjects(array('clientid=' => $clientid)); $projects = array(); foreach ($this->view->projects as $project) { $projects[] = array('id' => $project->id, 'title' => $project->title); } echo Zend_Json_Encoder::encode($projects); // $this->renderRawView('project/clientprojects.php'); }
public function execute() { return; // go through each project that has reportgeneration = true $projects = $this->projectService->getProjects(array('enablereports=' => 1)); $userProjectMapping = new ArrayObject(); foreach ($projects as $project) { /* @var $project Project */ // Create the status report and notify the manager to go and check it out $report = $this->projectService->getProjectStatus($project); $report->title = "Report generated " . date('Y-m-d'); $report->completednotes = "TO BE FILLED IN BY " . $project->manager; $report->todonotes = "TO BE FILLED IN BY " . $project->manager; $this->projectService->saveStatus($report); // email the manager! $userProjects = ifset($userProjectMapping, $project->manager, array()); $userProjects[] = $project; $userProjectMapping[$project->manager] = $userProjects; } foreach ($userProjectMapping as $user => $projects) { $msg = new TemplatedMessage('status-report-created.php', array('projects' => $projects)); $this->notificationService->notifyUser('Project status reports reminder', $user, $msg); } }
/** * Edit an expense report */ public function editreportAction($model = null) { $cid = $this->_getParam('clientid'); $client = null; if ($cid) { $client = $this->byId($cid, 'Client'); } $user = $this->userService->getUserByField('username', $this->_getParam('username')); if (!$user && !$client) { throw new Exception("Must specify a client or user"); } $this->view->expenses = array(); if ($client) { $this->view->client = $client; $this->view->projects = $this->projectService->getProjects(array('clientid=' => $cid)); } else { $this->view->client = new Client(); $this->view->projects = array(); } if ($user) { $this->view->user = $user; } else { $this->view->user = new CrmUser(); } if ($model == null) { if ((int) $this->_getParam('id')) { $this->view->model = $this->byId(null, 'ExpenseReport'); // $this->dbService->getById((int)$this->_getParam('id'), $modelType); if ($client) { $this->view->expenses = $this->expenseService->getExpenses(array('expensereportid=' => $this->view->model->id)); } else { $this->view->expenses = $this->expenseService->getExpenses(array('userreportid=' => $this->view->model->id)); } } else { $this->view->model = new ExpenseReport(); } } else { $this->view->model = $model; } $this->view->clients = $this->clientService->getClients(); $this->view->users = $this->userService->getUserList(); $this->renderView('expense/editreport.php'); }
/** * Get the task that represents the leave for a given leave application * and add some time to it for the given application */ public function applyTimeForLeave(LeaveApplication $leaveApplication) { $project = $this->projectService->getProject(za()->getConfig('leave_project')); if (!$project) { throw new Exception("Leave project not set correctly in configuration"); } $monthYear = date('F Y', strtotime($leaveApplication->to)); $params = array('parentid=' => $project->id, 'title=' => $monthYear); // get the appropriate milestone $projs = $this->projectService->getProjects($params); $milestone = null; if (count($projs)) { $milestone = $projs[0]; } else { // create a new milestone // $milestone $date = date('Y-m-t', strtotime($leaveApplication->to)) . ' 23:59:59'; $milestone = $this->projectService->createMilestone($project, $monthYear, $date); } // now get the task for the given leave app $taskTitle = $leaveApplication->leavetype . ' Leave #' . $leaveApplication->id . ': ' . $leaveApplication->username . ' ' . date('Y-m-d', strtotime($leaveApplication->from)) . ' - ' . date('Y-m-d', strtotime($leaveApplication->to)); $params = array('projectid=' => $milestone->id, 'title=' => $taskTitle); $tasks = $this->projectService->getTasks($params); $user = $this->getUserByField('username', $leaveApplication->username); $task = null; if (count($tasks)) { $task = $tasks[0]; // delete all timesheet entries for this user on this task $records = $this->projectService->getDetailedTimesheet($user, $task->id); foreach ($records as $record) { $this->projectService->removeTimesheetRecord($record); } } else { // create the new task $task = new Task(); za()->inject($task); $task->title = $taskTitle; $task->projectid = $milestone->id; $task->category = 'Leave'; $task->due = $leaveApplication->to; $task->description = $leaveApplication->reason; $task->estimated = za()->getConfig('day_length') * $leaveApplication->days; $task->complete = 1; $task = $this->projectService->saveTask($task); } if ($task != null) { // now add all the timesheet entries for each given day $startTime = strtotime(date('Y-m-d', strtotime($leaveApplication->from)) . ' 09:00:00'); // now go through and add time for the given day for ($i = 0; $i < $leaveApplication->days; $i++) { // see if today's a weekend, if so we want to skip til the next monday $curDay = date('D', $startTime); if ($curDay == 'Sat') { $startTime += 2 * 86400; } else { if ($curDay == 'Sun') { $startTime += 86400; } } $endTime = $startTime + za()->getConfig('day_length') * 3600; $this->projectService->addTimesheetRecord($task, $user, $startTime, $endTime); $startTime += 86400; } } }