本文整理汇总了PHP中Task::getTasksArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::getTasksArray方法的具体用法?PHP Task::getTasksArray怎么用?PHP Task::getTasksArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::getTasksArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: HookManager
/**
* Fonction generant le projet sur le disque
*
* @param Project $object Object project a generer
* @param Translate $outputlangs Lang output object
* @return int 1 if OK, <=0 if KO
*/
function write_file($object, $outputlangs)
{
global $conf, $hookmanager, $langs, $user;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("projects");
if ($conf->projet->dir_output) {
//$nblignes = count($object->lines); // This is set later with array of tasks
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->projet->dir_output;
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/" . $objectref;
}
$file = $dir . "/" . $objectref . ".pdf";
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
if (file_exists($dir)) {
// Add pdfgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action);
// Note that $action and $object may have been modified by some hooks
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
// Must be after pdf_getInstance
$heightforinfotot = 50;
// Height reserved to output the info and total part
$heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5;
// Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8;
// Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Complete object by loading several other informations
$task = new Task($this->db);
$tasksarray = $task->getTasksArray(0, 0, $object->id);
if (!$object->id > 0) {
$tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
}
$object->lines = $tasksarray;
$nblignes = count($object->lines);
$pdf->Open();
$pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Project"));
$pdf->SetCreator("Dolibarr " . DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Project"));
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
$pdf->SetCompression(false);
}
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
// Left, Top, Right
// New page
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(0, 3, '');
// Set interline to 3
$pdf->SetTextColor(0, 0, 0);
$tab_top = 50;
$tab_height = 200;
$tab_top_newpage = 40;
$tab_height_newpage = 210;
// Affiche notes
if (!empty($object->note_public)) {
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
$height_note = $nexY - ($tab_top - 2);
//.........这里部分代码省略.........
示例2:
print '<br>';
// Link to switch in "my task" / "all task"
print '<table width="100%"><tr><td align="right">';
if ($mode == 'mine') {
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '">' . $langs->trans("DoNotShowMyTasksOnly") . '</a>';
//print ' - ';
//print $langs->trans("ShowMyTaskOnly");
} else {
//print $langs->trans("DoNotShowMyTaskOnly");
//print ' - ';
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&mode=mine">' . $langs->trans("ShowMyTasksOnly") . '</a>';
}
print '</td></tr></table>';
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him).
$tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
// We load also tasks limited to a particular user
$tasksrole = $mode == 'mine' ? $taskstatic->getUserRolesForProjectsOrTasks(0, $user, $object->id, 0) : '';
//var_dump($tasksarray);
//var_dump($tasksrole);
if (!empty($conf->use_javascript_ajax)) {
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}
print '<table id="tablelines" class="noborder" width="100%">';
print '<tr class="liste_titre nodrag nodrop">';
// print '<td>'.$langs->trans("Project").'</td>';
print '<td width="100">' . $langs->trans("RefTask") . '</td>';
print '<td>' . $langs->trans("LabelTask") . '</td>';
print '<td align="center">' . $langs->trans("DateStart") . '</td>';
print '<td align="center">' . $langs->trans("DateEnd") . '</td>';
print '<td align="right">' . $langs->trans("PlannedWorkload") . '</td>';
示例3: foreach
// Get list of project id allowed to user (in a string list separated by coma)
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $mine, 1, $socid);
//var_dump($projectsListId);
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task assigned to a user can have a parent that is not assigned to him and we need such parents).
$morewherefilter = '';
if ($search_all) {
$morewherefilter .= natural_search(array_keys($fieldstosearchall), $search_all);
}
if ($search_task_ref) {
$morewherefilter .= natural_search('t.ref', $search_task_ref);
}
if ($search_task_label) {
$morewherefilter .= natural_search('t.label', $search_task_label);
}
$tasksarray = $taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_status, $morewherefilter, $search_project_user, 0);
// We don't use filter on task user. Because sometimes a task is assigned but not the parent one and we want to show also parent, so filtering is done during output
$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $tuser->id ? $tuser : null, $projectstatic->id, 0, $search_status);
// We load also tasks limited to a particular user
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
}
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
print '<input type="hidden" name="type" value="' . $type . '">';
if ($search_all) {
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
示例4:
$next_month = $next['mon'];
$next_day = $next['mday'];
$title = $langs->trans("TimeSpent");
if ($mine) {
$title = $langs->trans("MyTimeSpent");
}
$usertoprocess = $user;
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, 0, 1);
// Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
if ($id) {
$project->fetch($id);
$project->fetch_thirdparty();
}
$onlyopenedproject = 1;
// or -1
$tasksarray = $taskstatic->getTasksArray(0, 0, $project->id ? $project->id : 0, $socid, 0, '', $onlyopenedproject);
// We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, $project->id ? $project->id : 0, 0, $onlyopenedproject);
$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, $project->id ? $project->id : 0, 0, $onlyopenedproject);
//var_dump($tasksarray);
//var_dump($projectsrole);
//var_dump($taskrole);
llxHeader("", $title, "");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');
$param = $mode ? '&mode=' . $mode : '';
// Show navigation bar
$nav = "<a href=\"?year=" . $prev_year . "&month=" . $prev_month . "&day=" . $prev_day . $param . "\">" . img_previous($langs->trans("Previous")) . "</a>\n";
$nav .= " <span id=\"month_name\">" . dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "day") . " </span>\n";
$nav .= "<a href=\"?year=" . $next_year . "&month=" . $next_month . "&day=" . $next_day . $param . "\">" . img_next($langs->trans("Next")) . "</a>\n";
$nav .= " (<a href=\"?year=" . $nowyear . "&month=" . $nowmonth . "&day=" . $nowday . $param . "\">" . $langs->trans("Today") . "</a>)";
$nav .= '<br>' . $form->select_date(-1, '', 0, 0, 2, "addtime", 1, 0, 1) . ' ';
示例5: FormProjets
/**
* Fonction generant le projet sur le disque
*
* @param Project $object Object project a generer
* @param Translate $outputlangs Lang output object
* @return int 1 if OK, <=0 if KO
*/
function write_file($object, $outputlangs)
{
global $user, $langs, $conf;
$formproject = new FormProjets($this->db);
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("projects");
if ($conf->projet->dir_output) {
//$nblignes = count($object->lines); // This is set later with array of tasks
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->projet->dir_output;
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/" . $objectref;
}
$file = $dir . "/" . $objectref . ".pdf";
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
if (file_exists($dir)) {
// Add pdfgeneration hook
if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action);
// Note that $action and $object may have been modified by some hooks
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
// Must be after pdf_getInstance
$heightforinfotot = 50;
// Height reserved to output the info and total part
$heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5;
// Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8;
// Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Complete object by loading several other informations
$task = new Task($this->db);
$tasksarray = $task->getTasksArray(0, 0, $object->id);
$object->lines = $tasksarray;
$nblignes = count($object->lines);
$pdf->Open();
$pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Project"));
$pdf->SetCreator("Dolibarr " . DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Project"));
if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
$pdf->SetCompression(false);
}
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
// Left, Top, Right
// New page
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(0, 3, '');
// Set interline to 3
$pdf->SetTextColor(0, 0, 0);
$tab_top = 50;
$tab_height = 200;
$tab_top_newpage = 40;
$tab_height_newpage = 210;
// Affiche notes
if (!empty($object->note_public)) {
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
$height_note = $nexY - ($tab_top - 2);
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192, 192, 192);
//.........这里部分代码省略.........
示例6: HookManager
//.........这里部分代码省略.........
} catch (OdfException $e) {
}
}
// Replace tags of object + external modules
$tmparray = $this->get_substitutionarray_object($object, $outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action);
// Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $value) {
try {
if (preg_match('/logo$/', $key)) {
if (file_exists($value)) {
$odfHandler->setImage($key, $value);
} else {
$odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
} else {
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
} catch (OdfException $e) {
}
}
// Replace tags of lines for tasks
try {
$listlines = $odfHandler->setSegment('tasks');
$taskstatic = new Task($this->db);
// Security check
$socid = 0;
if (!empty($object->fk_soc)) {
$socid = $object->fk_soc;
}
$tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
foreach ($tasksarray as $task) {
$tmparray = $this->get_substitutionarray_tasks($task, $outputlangs);
//complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
foreach ($tmparray as $key => $val) {
try {
$listlines->setVars($key, $val, true, 'UTF-8');
} catch (OdfException $e) {
} catch (SegmentException $e) {
}
}
$taskobj = new Task($this->db);
$taskobj->fetch($task->id);
// Replace tags of lines for contacts task
$sourcearray = array('internal', 'external');
$contact_arrray = array();
foreach ($sourcearray as $source) {
$contact_temp = $taskobj->liste_contact(-1, $source);
if (is_array($contact_temp) && count($contact_temp) > 0) {
$contact_arrray = array_merge($contact_arrray, $contact_temp);
}
}
if (is_array($contact_arrray) && count($contact_arrray) > 0) {
$listlinestaskres = $listlines->__get('tasksressources');
foreach ($contact_arrray as $contact) {
if ($contact['source'] == 'internal') {
$objectdetail = new User($this->db);
$objectdetail->fetch($contact['id']);
$contact['socname'] = $mysoc->name;
} elseif ($contact['source'] == 'external') {
$objectdetail = new Contact($this->db);
$objectdetail->fetch($contact['id']);
$soc = new Societe($this->db);
示例7: Project
$project = new Project($db);
$taskstatic = new Task($db);
$title = $langs->trans("TimeSpent");
if ($mine) {
$title = $langs->trans("MyTimeSpent");
}
//$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
// Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
if ($id) {
$project->fetch($id);
$project->fetch_thirdparty();
}
$onlyopened = 1;
// or -1
$tasksarray = $taskstatic->getTasksArray(0, 0, $project->id ? $project->id : $projectsListId, $socid, 0, '', $onlyopened);
// We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($user, 0, $project->id ? $project->id : $projectsListId, 0);
$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $user, $project->id ? $project->id : $projectsListId, 0);
//var_dump($tasksarray);
//var_dump($projectsrole);
//var_dump($taskrole);
llxHeader("", $title, "");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
// Show description of content
if ($mine) {
print $langs->trans("MyTasksDesc") . ($onlyopened ? ' ' . $langs->trans("OnlyOpenedProject") : '') . '<br><br>';
} else {
if ($user->rights->projet->all->lire && !$socid) {
print $langs->trans("ProjectsDesc") . ($onlyopened ? ' ' . $langs->trans("OnlyOpenedProject") : '') . '<br><br>';
} else {
示例8:
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
// Show description of content
if ($mine) print $langs->trans("MyProjectsDesc").'<br><br>';
else
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'<br><br>';
else print $langs->trans("ProjectsPublicDesc").'<br><br>';
}
// Get list of project id allowed to user
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user
// can have a parent that is not affected to him).
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
// We load also tasks limited to a particular user
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
print '<td width="80">'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n";
// Show all lines in taskarray (recursive function to go down on tree)
$j=0; $level=0;
$nboftaskshown=PLines($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId);
print "</table>";
示例9:
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'">'.$langs->trans("DoNotShowMyTasksOnly").'</a>';
//print ' - ';
//print $langs->trans("ShowMyTaskOnly");
}
else
{
//print $langs->trans("DoNotShowMyTaskOnly");
//print ' - ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'&mode=mine">'.$langs->trans("ShowMyTasksOnly").'</a>';
}
print '</td></tr></table>';
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user
// can have a parent that is not affected to him).
$tasksarray=$task->getTasksArray(0, 0, $project->id, $socid, 0);
// We load also tasks limited to a particular user
$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$project->id,0) : '');
//var_dump($tasksarray);
//var_dump($tasksrole);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
if ($projectstatic->id) print '<td>'.$langs->trans("Project").'</td>';
print '<td width="80">'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print "</tr>\n";
if (sizeof($tasksarray) > 0)
{
示例10: selectProjectTasks
/**
* Return list of project and tasks
*
* @param int $selectedtask Pre-selected task
* @param int $projectid Project id
* @param string $htmlname Name of html select
* @param int $modeproject 1 to restrict on projects owned by user
* @param int $modetask 1 to restrict on tasks associated to user
* @param int $mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
* @param int $useempty 0=Allow empty values
* @param int $disablechildoftaskid 1=Disable task that are child of the provided task id
* @return void
*/
function selectProjectTasks($selectedtask = '', $projectid = 0, $htmlname = 'task_parent', $modeproject = 0, $modetask = 0, $mode = 0, $useempty = 0, $disablechildoftaskid = 0)
{
global $user, $langs;
require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php';
//print $modeproject.'-'.$modetask;
$task = new Task($this->db);
$tasksarray = $task->getTasksArray($modetask ? $user : 0, $modeproject ? $user : 0, $projectid, 0, $mode);
if ($tasksarray) {
print '<select class="flat" name="' . $htmlname . '">';
if ($useempty) {
print '<option value="0"> </option>';
}
$j = 0;
$level = 0;
$this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid);
print '</select>';
} else {
print '<div class="warning">' . $langs->trans("NoProject") . '</div>';
}
}
示例11:
$title=$langs->trans("TimeSpent");
if ($mine) $title=$langs->trans("MyTimeSpent");
$usertoprocess = $user;
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
if ($id)
{
$project->fetch($id);
$project->fetch_thirdparty();
}
$onlyopenedproject=1; // or -1
$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject);
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject);
//var_dump($tasksarray);
//var_dump($projectsrole);
//var_dump($taskrole);
llxHeader("",$title,"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project');
$param=($mode?'&mode='.$mode:'');
// Show navigation bar
$nav ="<a href=\"?year=".$prev_year."&month=".$prev_month."&day=".$prev_day.$param."\">".img_previous($langs->trans("Previous"))."</a>\n";
示例12: count
/**
* Fonction generant le projet sur le disque
*
* @param Project $object Object project a generer
* @param Translate $outputlangs Lang output object
* @return int 1 if OK, <=0 if KO
*/
function write_file($object, $outputlangs)
{
global $user, $langs, $conf;
if (!is_object($outputlangs)) {
$outputlangs = $langs;
}
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (!empty($conf->global->MAIN_USE_FPDF)) {
$outputlangs->charset_output = 'ISO-8859-1';
}
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("projects");
if ($conf->projet->dir_output) {
$nblignes = count($object->lines);
$default_font_size = pdf_getPDFFontsize($outputlangs);
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->projet->dir_output;
if (!preg_match('/specimen/i', $objectref)) {
$dir .= "/" . $objectref;
}
$file = $dir . "/" . $objectref . ".pdf";
if (!file_exists($dir)) {
if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
if (file_exists($dir)) {
$pdf = pdf_getInstance($this->format);
if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Complete object by loading several other informations
$task = new Task($this->db);
$tasksarray = $task->getTasksArray(0, 0, $object->id);
$object->lines = $tasksarray;
$nblignes = count($object->lines);
$pdf->Open();
$pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Project"));
$pdf->SetCreator("Dolibarr " . DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Project"));
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) {
$pdf->SetCompression(false);
}
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
// Left, Top, Right
$pdf->SetAutoPageBreak(1, 0);
// New page
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(0, 3, '');
// Set interline to 3
$pdf->SetTextColor(0, 0, 0);
$tab_top = 50;
$tab_height = 200;
$tab_top_newpage = 40;
$tab_height_newpage = 210;
// Affiche notes
if (!empty($object->note_public)) {
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
$height_note = $nexY - ($tab_top - 2);
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192, 192, 192);
$pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
$tab_height = $tab_height - $height_note;
$tab_top = $nexY + 6;
} else {
$height_note = 0;
}
$iniY = $tab_top + 7;
$curY = $tab_top + 7;
$nexY = $tab_top + 7;
// Boucle sur les lignes
for ($i = 0; $i < $nblignes; $i++) {
$curY = $nexY;
// Description of ligne
$ref = $object->lines[$i]->ref;
$libelleline = $object->lines[$i]->label;
$progress = $object->lines[$i]->progress . '%';
$datestart = dol_print_date($object->lines[$i]->date_start, 'day');
$dateend = dol_print_date($object->lines[$i]->date_end, 'day');
//.........这里部分代码省略.........
示例13: Form
$form = new Form($db);
$projectstatic = new Project($db);
$project = new Project($db);
$taskstatic = new Task($db);
$title = $langs->trans("TimeSpent");
if ($mine) {
$title = $langs->trans("MyTimeSpent");
}
//$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
// Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project
if ($id) {
$project->fetch($id);
$project->societe->fetch($project->societe->id);
}
$tasksarray = $taskstatic->getTasksArray(0, 0, $project->id ? $project->id : $projectsListId, $socid, 0);
// We want to see all task of project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole = $taskstatic->getUserRolesForProjectsOrTasks($user, 0, $project->id ? $project->id : $projectsListId, 0);
$tasksrole = $taskstatic->getUserRolesForProjectsOrTasks(0, $user, $project->id ? $project->id : $projectsListId, 0);
//var_dump($tasksarray);
//var_dump($projectsrole);
//var_dump($taskrole);
llxHeader("", $title, "");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
// Filter on user
/* dol_fiche_head('');
print '<table class="border" width="100%"><tr><td width="25%">'.$langs->trans("User").'</td>';
print '<td>';
if ($mine) print $user->getLoginUrl(1);
print '</td>';
print '</tr></table>';
示例14:
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
// Show description of content
if ($mine) print $langs->trans("MyProjectsDesc").'<br><br>';
else
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'<br><br>';
else print $langs->trans("ProjectsPublicDesc").'<br><br>';
}
// Get list of project id allowed to user
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him).
$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_product);
// We load also tasks limited to a particular user
$tasksrole=($mine ? $taskstatic->getUserRolesForProjectsOrTasks(0,$user,$projectstatic->id,0) : '');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="mode" value="'.GETPOST('mode').'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Project").'</td>';
print '<td width="80">'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="center">'.$langs->trans("DateStart").'</td>';
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
print '<td align="right">'.$langs->trans("Progress").'</td>';
示例15: shiftTaskDate
/**
* Shift project task date from current date to delta
*
* @param timestamp $old_project_dt_start old project start date
* @return int 1 if OK or < 0 if KO
*/
function shiftTaskDate($old_project_dt_start)
{
global $user, $langs, $conf;
$error = 0;
$taskstatic = new Task($this->db);
// Security check
$socid = 0;
if ($user->societe_id > 0) {
$socid = $user->societe_id;
}
$tasksarray = $taskstatic->getTasksArray(0, 0, $this->id, $socid, 0);
foreach ($tasksarray as $tasktoshiftdate) {
$to_update = false;
// Fetch only if update of date will be made
if (!empty($tasktoshiftdate->date_start) || !empty($tasktoshiftdate->date_end)) {
//dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG);
$to_update = true;
$task = new Task($this->db);
$result = $task->fetch($tasktoshiftdate->id);
if (!$result) {
$error++;
$this->error .= $task->error;
}
}
//print "$this->date_start + $tasktoshiftdate->date_start - $old_project_dt_start";exit;
//Calcultate new task start date with difference between old proj start date and origin task start date
if (!empty($tasktoshiftdate->date_start)) {
$task->date_start = $this->date_start + ($tasktoshiftdate->date_start - $old_project_dt_start);
}
//Calcultate new task end date with difference between origin proj end date and origin task end date
if (!empty($tasktoshiftdate->date_end)) {
$task->date_end = $this->date_start + ($tasktoshiftdate->date_end - $old_project_dt_start);
}
if ($to_update) {
$result = $task->update($user);
if (!$result) {
$error++;
$this->error .= $task->error;
}
}
}
if ($error != 0) {
return -1;
}
return $result;
}