Loading

Add custom fields? [2.0]

Get help with problems, or report & discuss bugs in Collabtive

Add custom fields? [2.0]

Postby dadid » 26.01.2017, 13:13

Hi,
I have a problem with adding a new field like the budget in tasks and show it e.g. on the task list, but show only USD.
I tried to add it in 3.0, but does not work well.

I edited in :
--------------
class.task.php
function add($start, $end, $title, $text, $liste, $project, $budget2)
...
// write to db
$insStmt = $conn->prepare("INSERT INTO tasks (start, end, title, text, liste, status, project, budget2) VALUES (?, ?, ?, ?, ?, 1, ?, ?)");
$ins = $insStmt->execute(array($start_fin, $end_fin, $title, $text, $liste, $project, $budget2));

...
function edit($id, $start, $end, $title, $text, $liste, $budget2)
{
global $conn;
$id = (int) $id;
$liste = (int) $liste;
$title = htmlspecialchars($title);
$budget2 = (float) $budget2;

//convert time string to timestamp
$start = strtotime($start);
$end = strtotime($end);

$updStmt = $conn->prepare("UPDATE tasks SET `start`=?, `end`=?, `title`=?, `text`=?, `liste`=?, budget2=? WHERE ID = ?");
$upd = $updStmt->execute(array($start, $end, $title, $text, $liste, $budget2, $id));
...
}
----------
In addtask.tpl I added this budget2 to language file

<div class="row">
<label for="budget2">{#budget2#}:</label>
<input type="text" class="text" name="budget2" id="budget2" />
</div>
------------
In managetask.php I addet last line

$task = (object) new task();

$tasklist = getArrayVal($_GET, "tasklist");
$mode = getArrayVal($_GET, "mode");
$tid = getArrayVal($_GET, "tid");
$start = getArrayVal($_POST, "start");
$end = getArrayVal($_POST, "end");
$project = getArrayVal($_POST, "project");
$assigned = getArrayVal($_POST, "assigned");
$tasklist = getArrayVal($_POST, "tasklist");
$text = getArrayVal($_POST, "text");
$title = getArrayVal($_POST, "title");
$redir = getArrayVal($_GET, "redir");
$id = getArrayVal($_GET, "id");
$budget2 = getArrayVal($_POST, "budget2");

...
// add the task
$tid = $task->add($start, $end, $title, $text, $tasklist, $id, $budget2);

----------

And in projecttask.tpl I added another column

...
<div class="nosmooth" id="sm_{$lists[list].ID}">
<table id="acc_{$lists[list].ID}" cellpadding="0" cellspacing="0" border="0">

<thead>
<tr>
<th class="a"></th>
<th class="b">{#tasks#}</th>
<th class="c">{#budget2#}</th>
<th class="c">{#user#}</th>
<th class="days" style="text-align:right">{#daysleft#}&nbsp;USD&nbsp;</th>
<th class="tools"></th>
</tr>
</thead>

<tfoot>
<tr>
<td colspan="5"></td>
</tr>
</tfoot>

{section name=task loop=$lists[list].tasks}
{*Color-Mix*}
{if $smarty.section.task.index % 2 == 0}
<tbody class="color-a" id="task_{$lists[list].tasks[task].ID}">
{else}
<tbody class="color-b" id="task_{$lists[list].tasks[task].ID}">
{/if}
<tr {if $lists[list].tasks[task].daysleft < 0} class="marker-late"{elseif $lists[list].tasks[task].daysleft == 0} class="marker-today"{/if}>
<td>
{if $userpermissions.tasks.close}
<a class="butn_check" href="javascript:closeElement('task_{$lists[list].tasks[task].ID}','managetask.php?action=close&amp;tid={$lists[list].tasks[task].ID}&amp;id={$project.ID}');" title="{#close#}"></a>
{/if}
</td>
<td>
<div class="toggle-in">
<span class="acc-toggle" onclick="javascript:accord_{$lists[list].ID}.activate($$('#acc_{$lists[list].ID} .accordion_toggle')[{$smarty.section.task.index}]);toggleAccordeon('acc_{$lists[list].ID}',this);"></span>
<a href="managetask.php?action=showtask&amp;tid={$lists[list].tasks[task].ID}&amp;id={$lists[list].tasks[task].project}" title="{$lists[list].tasks[task].title}">
{if $lists[list].tasks[task].title != ""}
{$lists[list].tasks[task].title|truncate:30:"...":true}
{else}
{$lists[list].tasks[task].text|truncate:30:"...":true}
{/if}
</a>
</div>
</td>
<td style="text-align:right">{$lists[list].tasks[task].budget2}&nbsp;&nbsp;</td>
<td>

----------
dadid
 
Posts: 5
Joined: 26.01.2017, 12:26

Re: Add custom fields? [2.0]

Postby Eva » 04.02.2017, 20:54

Nice work on customizing Collabtive to fit your own needs! :)
Unfortunately it is difficult to read so many lines of code without any context and highlighting.

To make it easier for people to help you, I'd suggest forking Collabtive on GitHub:
https://github.com/philippK-de/Collabtive
Project Management the way you like it: Collaborative - Open Source - Free

facebook.com/Collabtive
twitter.com/Collabtive
xing.com/companies/collabtive
linkedin.com/company/collabtive
User avatar
Eva
 
Posts: 1471
Joined: 01.01.2008, 23:31
Location: Saarbrücken, Germany


Return to Problems and Bugs

Who is online

Users browsing this forum: No registered users