本文整理汇总了PHP中Companies::findByProject方法的典型用法代码示例。如果您正苦于以下问题:PHP Companies::findByProject方法的具体用法?PHP Companies::findByProject怎么用?PHP Companies::findByProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Companies
的用法示例。
在下文中一共展示了Companies::findByProject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export
/**
* Exports time records
*
* @param void
* @return null
*/
function export()
{
$object_visibility = array_var($_GET, 'visibility', VISIBILITY_NORMAL);
$exportable_modules = explode(',', array_var($_GET, 'modules', null));
if (!is_foreachable($exportable_modules)) {
$exportable_modules = null;
}
// if
require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php';
$output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, $this->active_module, $exportable_modules);
if (!$output_builder->createOutputFolder()) {
$this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON);
}
// if
$output_builder->createAttachmentsFolder();
$timerecords = TimeRecords::findByProject($this->active_project, STATE_VISIBLE, $object_visibility);
$distinct_months = array();
foreach ($timerecords as $timerecord) {
$date = $timerecord->getRecordDate();
$exists = false;
for ($x = 0; $x < count($distinct_months); $x++) {
if ($distinct_months[$x]['month'] == $date->getMonth() && $distinct_months[$x]['year'] == $date->getYear()) {
$exists = true;
}
// if
}
// for
if (!$exists) {
$distinct_months[] = array("year" => $date->getYear(), "month" => $date->getMonth(), "month_string" => $date->date_data['month'], "beginning_of_month" => DateTimeValue::beginningOfMonth($date->getMonth(), $date->getYear()), "end_of_month" => DateTimeValue::endOfMonth($date->getMonth(), $date->getYear()));
}
// if
}
// foreach
$people = ProjectUsers::findUsersByProject($this->active_project);
$companies = Companies::findByProject($this->active_project);
$total_times = array();
foreach ($people as $person) {
$person->temp_total_time = TimeRecords::getTotalUserTimeOnProject($this->active_project, $person);
}
// foreach
$output_builder->setFileTemplate($this->active_module, $this->controller_name, 'index');
$output_builder->smarty->assign(array("distinct_months" => $distinct_months, "people" => $people, "companies" => $companies, "total_times" => $total_times, "timerecords" => $timerecords));
$output_builder->outputToFile('index');
// export monthly report
if (is_foreachable($distinct_months)) {
$output_builder->setFileTemplate($this->active_module, $this->controller_name, 'monthly');
foreach ($distinct_months as $distinct_month) {
$output_builder->smarty->assign(array('current_month' => $distinct_month, 'start_date' => DateTimeValue::beginningOfMonth($distinct_month[month], $distinct_month['year']), 'end_date' => DateTimeValue::endOfMonth($distinct_month['month'], $distinct_month['year'])));
$output_builder->outputToFile('monthly_' . $distinct_month['month'] . '_' . $distinct_month['year']);
}
// foreach
}
// if
// export report for persons
if (is_foreachable($people)) {
$output_builder->setFileTemplate($this->active_module, $this->controller_name, 'person');
foreach ($people as $person) {
$output_builder->smarty->assign(array('current_person' => $person));
$output_builder->outputToFile('user_' . $person->getId());
}
// foreach
}
// if
$this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON);
}