public function execute() { $updateTime = date('Y-m-d H:i:s', $this->lastRun); $select = $this->dbService->select(); $select->from('project')->joinInner('task', 'task.projectid = project.id', new Zend_Db_Expr('task.id as taskid'))->where("task.updated > ?", $updateTime); $projects = $this->dbService->fetchObjects('Project', $select); $done = array(); foreach ($projects as $project) { if (in_array($project->id, $done)) { continue; } $done[] = $project->id; echo "Updating time for project #{$project->id} " . $project->title . "\n"; $this->projectService->updateProjectEstimate($project); } $select = $this->dbService->select(); $select->from('project')->joinInner('feature', 'feature.projectid = project.id', new Zend_Db_Expr('feature.id as featureid'))->where("feature.updated > ?", $updateTime); $projects = $this->dbService->fetchObjects('Project', $select); foreach ($projects as $project) { if (in_array($project->id, $done)) { continue; } $done[] = $project->id; echo "Updating time for project #{$project->id} " . $project->title . "\n"; $this->projectService->updateProjectEstimate($project); } }
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'); }
/** * Get the items that need to appear in the project listing */ public function projectlistAction() { // $project = $this->projectService->getProject((int) $this->_getParam('projectid')); $project = $this->projectService->getProject((int) $this->_getParam('projectid')); $this->view->invoices = $this->dbService->getObjects('Invoice', array('projectid=' => $project->id)); $this->view->model = $project; $this->renderRawView('invoice/ajax-invoice-list.php'); }
public function import($project, $filename) { $handle = fopen($filename, "r"); $fields = fgetcsv($handle, 1000, ","); $detail = array(); while ($data = fgetcsv($handle, 1000, ",")) { $detail[] = $data; } $x = 0; $y = 0; if (!in_array('Name', $fields)) { throw new Exception("Malformed input file"); } $errors = array(); $lines = array(); foreach ($detail as $i) { if (count($i) != count($fields)) { continue; } foreach ($fields as $z) { $fieldName = trim($z); if (!mb_strlen($fieldName)) { ++$y; continue; } $lines[$x][$fieldName] = trim($i[$y]); ++$y; } $y = 0; $x++; } $errors = array(); $number = 0; foreach ($lines as $line) { // Get the task if it exists $title = $line['Name']; if (!mb_strlen($title)) { continue; } $existing = $this->projectService->getTasks(array('projectid=' => $project->id, 'title=' => $line['Name'], 'complete=' => 0)); if (count($existing)) { $task = $existing[0]; } else { $task = new Task(); } $task->title = $line['Name']; $task->startdate = $this->getDate($line['Begin date']); $task->due = $this->getDate($line['End date']); $task->description = $line['Notes']; if (mb_strlen($line['Resources'])) { $users = split(';', $line['Resources']); $task->userid = $users; } $task->projectid = $project->id; // save the updated task info $this->projectService->saveTask($task); } }
public function setReportCriteriaInfoInRequest($formValues) { $projectService = new ProjectService(); $projectId = $formValues["project_name"]; $projectName = $projectService->getProjectNameWithCustomerName($projectId); $this->getRequest()->setParameter('projectName', $projectName); $this->getRequest()->setParameter('projectDateRangeFrom', $formValues["project_date_range"]["from"]); $this->getRequest()->setParameter('projectDateRangeTo', $formValues["project_date_range"]["to"]); }
public function setParametersForListComponent() { $projectService = new ProjectService(); $projectId = $this->getRequest()->getParameter("projectId"); $projectName = $projectService->getProjectNameWithCustomerName($projectId); $activityId = $this->getRequest()->getParameter("activityId"); $reportGeneratorService = new ReportGeneratorService(); $activityName = $reportGeneratorService->getProjectActivityNameByActivityId($activityId); $params = array('projectName' => $projectName, 'activityName' => $activityName, 'projectDateRangeFrom' => $this->getRequest()->getParameter("from"), 'projectDateRangeTo' => $this->getRequest()->getParameter("to"), 'total' => $this->getRequest()->getParameter("total")); return $params; }
/** * Gets all the names of available projects, including deleted projects. * @return array() $projectNameList */ private function _getProjectList() { $projectNameList = array(); $projectService = new ProjectService(); $projectList = $projectService->getActiveProjectsOrderedByCustomer(); if (!empty($projectList)) { foreach ($projectList as $project) { $projectNameList[-1] = __("All"); $projectNameList[$project->getProjectId()] = $project->getCustomer()->getName() . " - " . $project->getName(); } } else { $projectNameList[null] = "--" . __("No Projects") . "--"; } return $projectNameList; }
/** * Saves the order of the given ids. * */ public function saveorderAction() { $ids = $this->_getParam('ids'); if (!strlen($ids)) { $this->flash("Invalid IDs specified"); $this->renderView('error.php'); } $ids = split(',', $ids); if (count($ids)) { $feature = null; for ($i = 0, $c = count($ids); $i < $c; $i++) { $id = str_replace('featurelist_', '', $ids[$i]); $feature = $this->projectService->getFeature($id); /* @var $feature Feature */ if (!$feature) { continue; } $feature->sortorder = $i; $this->log->debug("Setting order for {$feature->title} to {$i}"); $this->projectService->saveFeature($feature); } if (!$this->_getParam('_ajax')) { $this->redirect('project', 'view', array('id' => $feature->projectid, '#features')); } } }
/** * Get a list of all the current user's tasks in JSON format * */ public function listAction() { if ($this->_getParam('_ajax')) { $this->renderRawView('task/list.php'); } else { $page = ifset($this->_getAllParams(), 'page', 1); $number = $this->_getParam('rp', za()->getConfig('project_list_size', 10)); $sort = $this->_getParam('sortname', 'due'); $order = $this->_getParam('sortorder', 'asc'); $items = $this->projectService->getUserTasks(za()->getUser(), array('complete=' => 0), 'task.' . $sort . ' ' . $order, $page, $number); $dummy = new Task(); $listFields = $dummy->listFields(); $asArr = array(); $aggrRow = array(); foreach ($items as $item) { $cell = array(); foreach ($listFields as $name => $display) { if (method_exists($item, $name)) { $cell[] = $item->{$name}(); } else { $cell[] = $item->{$name}; } } $row = array('id' => $item->id, 'cell' => $cell); $asArr[] = $row; } $obj = new stdClass(); $obj->page = ifset($this->_getAllParams(), 'page', 1); $obj->total = $items->getTotalResults(); $obj->rows = $asArr; $this->getResponse()->setHeader('Content-type', 'text/x-json'); $json = Zend_Json::encode($obj); echo $json; } }
/** * Notify the relevant people of a new issue * * @param unknown_type $issue */ private function notifyOfNewIssue($issue) { // get the group assigned to the project that this issue is against $project = $this->projectService->getProject($issue->projectid); $group = $this->groupService->getGroup($project->ownerid); // Only send if the group exists if ($group) { $users = $this->groupService->getUsersInGroup($group); $msg = new TemplatedMessage('new-issue.php', array('model' => $issue, 'project' => $project)); $this->notificationService->notifyUser("New request has been created", $users, $msg); } // if the new issue is a severity 1, then sms as well if ($issue->severity == Issue::SEVERITY_ONE) { $this->trackerService->track('sev1request', 'request-' . $issue->id); $user = $this->userService->getUserByField('username', $issue->userid); if ($user != null && $user->contactid) { $contactDetails = $this->clientService->getContact($user->contactid); if ($contactDetails && mb_strlen($contactDetails->mobile)) { // lets send a quick SMS if ($this->smsService->send("New Severity 1 request #" . $issue->id . ": " . $issue->title . ", please login and check ASAP!", $contactDetails->mobile)) { $this->trackerService->track('sendsms', 'request-' . $issue->id); } } } } }
private function checkProjectTaskPermissions($projectId) { if ($this->projectService->checkProjectOwner($projectId) or $this->projectService->checkProjectMember($projectId)) { return true; } return false; }
public function doView() { $projectService = new ProjectService(); $projectId = intval(Request::get("view_project_id")); $projectVo = $projectService->getByPrimary($projectId); View::set("ProjectViewValue", $projectVo); View::display("View"); }
public function setParametersForListComponent() { $projectService = new ProjectService(); $projectId = $this->getRequest()->getParameter("projectId"); $userRoleManager = $this->getContext()->getUserRoleManager(); $requiredPermissions = array(BasicUserRoleManager::PERMISSION_TYPE_DATA_GROUP => array('time_project_reports' => new ResourcePermission(true, false, false, false))); $accessible = $userRoleManager->isEntityAccessible('Project', $projectId, null, array(), array(), $requiredPermissions); $activityId = $this->getRequest()->getParameter("activityId"); $activity = $projectService->getProjectActivityById($activityId); if (!$accessible || $activity->getProjectId() != $projectId) { $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); } $projectName = $projectService->getProjectNameWithCustomerName($projectId); $reportGeneratorService = new ReportGeneratorService(); $activityName = $reportGeneratorService->getProjectActivityNameByActivityId($activityId); $params = array('projectName' => $projectName, 'activityName' => $activityName, 'projectDateRangeFrom' => $this->getRequest()->getParameter("from"), 'projectDateRangeTo' => $this->getRequest()->getParameter("to"), 'total' => $this->getRequest()->getParameter("total")); return $params; }
public function get() { $project = ProjectService::get(Request::get('id')); if ($project) { $this->asJson($project); } else { $this->asJson(false); } }
/** * Loads up a project select HTML control that can be ajaxed in * to replace any existing one. */ public function projectselectorAction() { $clientid = (int) $this->_getParam('clientid'); $this->view->fieldName = $this->_getParam('fieldName'); $this->view->selectorType = $this->_getParam('selectorType', 'any'); $this->view->empty = $this->_getParam('empty', 0); $this->view->projects = $this->projectService->getProjectsForClient($clientid); $this->renderRawView('project/project-selector.php'); $this->view->showMilestones = $this->_getParam('showMilestones'); }
/** * Get the items that need to appear in the project listing */ public function projectlistAction() { $project = $this->projectService->getProject((int) $this->_getParam('projectid')); $where = array('projectid=' => $project->id); $this->bindIssueListViewData($where); $this->view->model = $project; $this->view->attachedToType = 'projectid'; $this->view->minimal = true; $this->renderRawView('issue/list.php'); //ajax-issue-list.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); } }
/** * Get the support project for this client * * @param Client $client * @return Project */ public function getClientSupportProject(Client $client) { $project = $this->projectService->getProjectByField('title', $client->title . ' Support'); if (!$project) { $params = array(); $params['title'] = $client->title . ' Support'; $params['clientid'] = $client->id; $project = $this->projectService->saveProject($params); } /* @var $project Project */ if ($project->deleted) { $project->deleted = false; $this->projectService->saveProject($project); } return $project; }
/** * 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'); }
public function doExport() { // create a simple 2-dimensional array if (Request::get('type') == 'time') { $ordersService = new OrdersService(); $userCondition = new UserValue(); $userService = new UserService(); $ordersCondition = new OrdersValue(); $userlist = $userService->getlist($userCondition); //get project $projectCondition = new ProjectValue(); $projectService = new ProjectService(); $projectlist = $projectService->getList($projectCondition); //按时间范围搜索 $start = Request::get('start'); $end = Request::get('end'); $orderListModel = '所有派单'; if ($start != '' and $end != '') { $ordersCondition->addAddtimeCondition($start, Value::GREATER_EQUAL); $ordersCondition->addAddtimeCondition($end, Value::LESS_EQUAL); $orderListModel = '从' . $start . ' 到 ' . $end . '的派单'; } elseif ($end == '' and $start != '') { $ordersCondition->addAddtimeCondition($end, Value::LESS_EQUAL); $orderListModel = '从' . $start . ' 到 今天 的派单'; } $ordersCondition->addCondition('1=1 ORDER BY `order_id` DESC'); $ordersList = $ordersService->getList($ordersCondition, $listPageHelper); $areaService = new AreaService(); $arealist = $areaService->getList(new AreaValue()); $array_top = array(); $array_top = array(Language::get("ORDERS.ADDTIME.LABEL"), Language::get("ORDERS.CUSTOMER_NAME.LABEL"), Language::get("ORDERS.CUSTOMER_ADDRESS.LABEL"), Language::get("ORDERS.PROJECT_ID.LABEL"), Language::get("ORDERS.HIS.LABEL"), Language::get("ORDERS.OPERATE_STATUS.LABEL"), Language::get("ORDERS.CONTACT_STATUS.LABEL"), Language::get("ORDERS.USER_ID.LABEL"), Language::get("ORDERS.INFO.LABEL")); $data[] = $array_top; if (count($ordersList) > 0) { foreach ($ordersList as $k => $v) { if (count($projectlist) > 0) { foreach ($projectlist as $project) { if ($v->project_id == $project->project_id) { $project = $project->project_name; break; } } } switch ($v->operate_status) { case Value::OPERATE_STATUS_NOT_OPERATE: $operate_status = '未成交'; break; case Value::OPERATE_STATUS_OPERATED: $operate_status = '已成交'; break; } switch ($v->contact_status) { case Value::CONTACT_STATUS_CANNOT_CONTACT: $contact_status = '无法联系'; break; case Value::CONTACT_STATUS_CONTACTED: $contact_status = '已联系'; break; case Value::CONTACT_STATUS_NOT_CONTACT: $contact_status = '未联系'; break; } if (count($userlist) > 0) { foreach ($userlist as $outUser) { if ($v->user_id == $outUser->user_id) { $user = $outUser->realname; break; } } } $data[] = array($v->addtime, $v->customer_name, $v->customer_address, $project, $v->HIS, $operate_status, $contact_status, $user, $v->info); } } // generate file (constructor parameters are optional) $xls = new Excel_XML('UTF-8', false, $orderListModel); $xls->addArray($data); $xls->generateXML('paidan'); } else { View::display('Export'); } }
/** * 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; } } }
public function getAllowedProjectList($role, $empNumber) { $projetService = new ProjectService(); return $projetService->getProjectListForUserRole($role, $empNumber); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id, $fileId) { $this->service->delete($fileId); }
public function update(Request $request, $id, $noteId) { return $this->service->update($request->all(), $noteId); }
/** * Delete Project Admin * @param sfWebRequest $request * @return unknown_type */ public function executeDeleteProjectActivity(sfWebRequest $request) { $projectId = $request->getParameter('id'); if (count($request->getParameter('chkLocID')) > 0) { $projectService = new ProjectService(); $projectService->deleteProjectActivities($request->getParameter('chkLocID')); $this->setMessage('SUCCESS', array(TopLevelMessages::DELETE_SUCCESS)); } else { $this->setMessage('NOTICE', array(TopLevelMessages::SELECT_RECORDS)); } $this->redirect('admin/listProjectActivity?id=' . $projectId); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id, $noteId) { return $this->service->destroy($noteId); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id, $projectMemberId) { $this->service->delete($projectMemberId); }
/** * Gets all the names of available projects, including deleted projects. * @return array() $projectNameList */ private function _getDataList() { $activityNameList = array(); $projectService = new ProjectService(); $projectList = $projectService->getActiveProjectList(); $projectId = -1; foreach ($projectList as $project) { $projectId = $project->getProjectId(); break; } $timesheetDao = new TimesheetDao(); $activityList = $timesheetDao->getProjectActivitiesByPorjectId($projectId); if ($activityList != null) { $activityNameList[-1] = __("All"); } else { $activityNameList[null] = "--" . __("No Project Activities") . "--"; } return $activityNameList; }
public function deleterecordAction() { $record = $this->byId(null, 'TimesheetRecord'); $this->projectService->removeTimesheetRecord($record); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id, $taskId) { return $this->service->destroy($taskId); }