/** * Renders the chart * @param IUser $logged_user * @return string */ function render(IUser $logged_user) { $db_result = DB::execute("SELECT milestone_id, COUNT(*) as count FROM " . TABLE_PREFIX . "project_objects WHERE project_id = ? AND type='Task' AND state >= ? AND visibility >= ? GROUP BY milestone_id", $this->project->getId(), STATE_VISIBLE, $logged_user->getMinVisibility()); $array_result = $db_result instanceof DBResult ? $db_result->toArrayIndexedBy('milestone_id') : false; if (is_foreachable($array_result)) { $pie_chart = new PieChart('400px', '400px', 'milestone_eta_report_pie_chart_placeholder'); $this->serie_array = array(); $this->milestones = array(); // Set data for the rest foreach ($array_result as $serie_data) { $point = new ChartPoint('1', $serie_data['count']); $serie = new ChartSerie($point); if (intval($serie_data['milestone_id'])) { $milestone = new RemediaMilestone(intval($serie_data['milestone_id'])); $label = PieChart::makeShortForPieChart($milestone->getName()); $this->milestones[] = $milestone; } else { $label = lang('No Milestone'); } //if $serie->setOption('label', $label); $this->serie_array[] = $serie; } //foreach $pie_chart->addSeries($this->serie_array); return $pie_chart->render(); } else { return '<p class="empty_slate">' . lang('There are no milestones in this project.') . '</p>'; } //if }
function frosso_estimated_cost_handle_on_after_object_save(ApplicationObject &$object) { if ($object instanceof Milestone && !$object instanceof RemediaMilestone) { if (isset($_POST['milestone']['custom_field_1']) && $_POST['milestone']['custom_field_1'] != '') { $remedia_mil = new RemediaMilestone($object->getId()); $remedia_mil->customFields()->setValue('custom_field_1', $_POST['milestone']['custom_field_1']); $remedia_mil->setNew(false); $remedia_mil->save(); } } }
function render() { $estimate = $this->object->tracking()->getEstimate(); if ($estimate instanceof Estimate) { $estimate_value = $estimate->getValue(); $estimate_autogenerated = $this->object->tracking()->isEstimateAutogenerated(); } else { $estimate_value = 0; $estimate_autogenerated = false; } // if $settings = array('value' => $estimate_value, 'summed_time' => $this->object->tracking()->sumTime(Authentication::getLoggedUser()), 'estimate_autogenerated' => $estimate_autogenerated, 'short_format' => true, 'can_change' => $this->object->tracking()->canEstimate(Authentication::getLoggedUser()), 'estimates_url' => $this->object->tracking()->getEstimatesUrl(), 'set_estimate_url' => $this->object->tracking()->getSetEstimateUrl(), 'object_id' => $this->object->getId()); return '(function (field, object, client_interface) { App.Inspector.Properties.MilestoneEstimation.apply(field, [object, ' . JSON::encode($settings) . ']); })'; }
function set_percent() { if ($this->request->isAsyncCall() || $this->request->isSubmitted()) { $milestone_id = $this->request->get('milestone_id', -1); $milestone = new RemediaMilestone($milestone_id); if ($milestone) { if ($this->request->isSubmitted()) { $percent = $this->request->post('percent', -1); if ($percent >= 0 && $percent <= 100) { $milestone->setPercentDone($percent); $milestone->save(); $this->response->respondWithData($milestone, array('as' => 'milestone', 'detailed' => true)); } else { $this->response->exception(new ValidationErrors(array('percent' => lang("Value must be between 0 and 100")))); } } $this->smarty->assign(array('milestone' => $milestone, 'form_action' => Router::assemble('frosso_ec_set_milestone_percent', array('project_slug' => $this->request->get('project_slug'), 'milestone_id' => $milestone_id)))); } else { $this->response->notFound(); } } else { $this->response->badRequest(""); } }