1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
18:
19: if (!isset($sortmode)) {
20: $sortmode = $currentuser->getUserProperty("system", "tasks_sortmode");
21: $sortby = $currentuser->getUserProperty("system", "tasks_sortby");
22: }
23:
24: $dateformat = getEffectiveSetting("dateformat", "full", "Y-m-d H:i:s");
25:
26: if (isset($_REQUEST["listsubmit"])) {
27: if (isset($c_restrict)) {
28: $c_restrict = true;
29: $currentuser->setUserProperty("mycontenido", "hidedonetasks", "true");
30: } else {
31: $c_restrict = false;
32: $currentuser->setUserProperty("mycontenido", "hidedonetasks", "false");
33: }
34: } else {
35: if ($currentuser->getUserProperty("mycontenido", "hidedonetasks") == "true") {
36: $c_restrict = true;
37: } else {
38: $c_restrict = false;
39: }
40: }
41:
42: 43: 44:
45: class TODOBackendList extends cGuiScrollList {
46:
47: 48: 49: 50:
51: var $statustypes;
52:
53: 54: 55:
56: function TODOBackendList() {
57: global $todoitems;
58:
59: parent::__construct();
60:
61: $this->statustypes = $todoitems->getStatusTypes();
62: $this->prioritytypes = $todoitems->getPriorityTypes();
63: }
64:
65: 66: 67: 68: 69: 70: 71:
72: function onRenderColumn($column) {
73: if ($column == 6 || $column == 5) {
74: $this->objItem->updateAttributes(array("align" => "center"));
75: } else {
76: $this->objItem->updateAttributes(array("align" => "left"));
77: }
78:
79: if ($column == 7) {
80: $this->objItem->updateAttributes(array("style" => "width: 85px;"));
81: } else {
82: $this->objItem->updateAttributes(array("style" => ""));
83: }
84: }
85:
86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97:
98: function convert($key, $value, $hidden) {
99: global $link, $dateformat, $cfg;
100:
101: $backendUrl = cRegistry::getBackendUrl();
102:
103: if ($key == 2) {
104: $link->setCustom("idcommunication", $hidden[1]);
105: $link->setContent($value);
106: return $link->render();
107: }
108:
109: if ($key == 3) {
110: return date($dateformat, strtotime($value));
111: }
112:
113: if ($key == 5) {
114: switch ($value) {
115: case "new":
116: $img = "status_new.gif";
117: break;
118: case "progress":
119: $img = "status_inprogress.gif";
120: break;
121: case "done":
122: $img = "status_done.gif";
123: break;
124: case "deferred":
125: $img = "status_deferred.gif";
126: break;
127: case "waiting":
128: $img = "status_waiting.gif";
129: break;
130: default:
131: break;
132: }
133:
134: if (!array_key_exists($value, $this->statustypes)) {
135: return i18n("No status type set");
136: }
137:
138: $backendUrl = cRegistry::getBackendUrl();
139:
140: $image = new cHTMLImage($backendUrl . $cfg["path"]["images"] . "reminder/" . $img);
141: $image->setAlt($this->statustypes[$value]);
142:
143:
144:
145: return $this->statustypes[$value];
146: }
147:
148: if ($key == 7) {
149: $amount = $value / 20;
150:
151: if ($amount < 0) {
152: $amount = 0;
153: }
154:
155: if ($amount > 5) {
156: $amount = 5;
157: }
158:
159: $amount = round($amount);
160:
161: if ($amount != 0) {
162: $image = new cHTMLImage($backendUrl . $cfg["path"]["images"] . "reminder/progress.gif");
163: $image->setAlt(sprintf(i18n("%d %% complete"), $value));
164: $ret = "";
165:
166: for ($i = 0; $i < $amount; $i++) {
167: $ret .= $image->render();
168: }
169:
170: return $ret;
171: } else {
172: return ' ';
173: }
174: }
175:
176: if ($key == 6) {
177: switch ($value) {
178: case 0:
179: $img = "prio_low.gif";
180: $p = "low";
181: break;
182: case 1:
183: $img = "prio_medium.gif";
184: $p = "medium";
185: break;
186: case 2:
187: $img = "prio_high.gif";
188: $p = "high";
189: break;
190: case 3:
191: $img = "prio_veryhigh.gif";
192: $p = "immediately";
193: break;
194: default:
195: break;
196: }
197:
198: $image = new cHTMLImage($backendUrl . $cfg["path"]["images"] . "reminder/" . $img);
199: $image->setAlt($this->prioritytypes[$p]);
200: return $image->render();
201: }
202:
203: if ($key == 8) {
204:
205: if ($value !== "") {
206: if (round($value, 2) == 0) {
207: return i18n("Today");
208: } else {
209: if ($value < 0) {
210: return number_format(0 - $value, 2, ',', '') . " " . i18n("Day(s)");
211: } else {
212: return '<font color="red">' . number_format(0 - $value, 2, ',', '') . " " . i18n("Day(s)") . '</font>';
213: }
214: }
215: } else {
216: return ' ';
217: }
218: }
219:
220: return $value;
221: }
222:
223: }
224:
225: if ($action == "todo_save_item") {
226: $subject = stripslashes($subject);
227: $message = stripslashes($message);
228:
229: $todoitem = new TODOItem();
230: $todoitem->loadByPrimaryKey($idcommunication);
231:
232: $todoitem->set("subject", $subject);
233: $todoitem->set("message", $message);
234: $todoitem->set("recipient", $userassignment);
235:
236: if (isset($reminderdate)) {
237: $todoitem->setProperty("todo", "reminderdate", strtotime($reminderdate));
238: }
239:
240: if (isset($notibackend)) {
241: $todoitem->setProperty("todo", "backendnoti", $notibackend);
242: }
243:
244: $todoitem->setProperty("todo", "emailnoti", $notiemail);
245:
246: $todoitem->setProperty("todo", "status", $status);
247:
248: if ($progress < 0) {
249: $progress = 0;
250: }
251:
252: if ($progress > 100) {
253: $progress = 100;
254: }
255:
256: $todoitem->setProperty("todo", "priority", $priority);
257: $todoitem->setProperty("todo", "progress", $progress);
258:
259: $todoitem->setProperty("todo", "enddate", $enddate);
260:
261: $todoitem->store();
262: }
263:
264: $cpage = new cGuiPage("mycontenido.tasks", "", "1");
265:
266: $todoitems = new TODOCollection();
267:
268: if ($action == "mycontenido_tasks_delete") {
269: $todoitems->delete($idcommunication);
270: }
271:
272: $recipient = $auth->auth["uid"];
273:
274: $todoitems->select("recipient = '" . $todoitems->escape($recipient) . "' AND idclient=" . (int) $client);
275:
276: $list = new TODOBackendList();
277:
278: $list->setHeader(
279: ' ', i18n("Subject"), i18n("Created"), i18n("End Date"), i18n("Status"),
280: i18n("Priority"), sprintf(i18n("%% complete")), i18n("Due in"), i18n("Actions")
281: );
282:
283: $lcount = 0;
284:
285: $link = new cHTMLLink();
286: $link->setCLink("mycontenido_tasks_edit", 4, "");
287: $link->setCustom("sortmode", $sortmode);
288: $link->setCustom("sortby", $sortby);
289:
290: while ($todo = $todoitems->next()) {
291: if ((($todo->getProperty("todo", "status") != "done") && ($c_restrict == true)) || ($c_restrict == '')) {
292:
293: $subject = $todo->get("subject");
294: $created = $todo->get("created");
295:
296: $reminder = $todo->getProperty("todo", "enddate");
297: $status = $todo->getProperty("todo", "status");
298: $priority = $todo->getProperty("todo", "priority");
299: $complete = $todo->getProperty("todo", "progress");
300:
301: if (trim($subject) == "") {
302: $subject = i18n("Unnamed item");
303: }
304:
305: if (trim($reminder) == "") {
306: $reminder = i18n("No end date set");
307: } else {
308: $reminder = date($dateformat, strtotime($reminder));
309: }
310:
311: if (trim($status) == "") {
312: $status = i18n("No status set");
313: }
314:
315: $link->setCustom("idcommunication", $todo->get("idcommunication"));
316: $link->setContent('<img id="myContenidoTodoButton" src="images/but_todo.gif" alt="" border="0">');
317:
318: $mimg = $link->render();
319:
320: $link->setContent($subject);
321:
322: $msubject = $link->render();
323:
324: $idcommunication = $todo->get("idcommunication");
325:
326: $delete = new cHTMLLink();
327: $delete->setCLink("mycontenido_tasks", 4, "mycontenido_tasks_delete");
328: $delete->setCustom("idcommunication", $idcommunication);
329: $delete->setCustom("sortby", $sortby);
330: $delete->setCustom("sortmode", $sortmode);
331:
332: $img = new cHTMLImage("images/delete.gif");
333: $img->setAlt(i18n("Delete item"));
334:
335: $delete->setContent($img->render());
336:
337: $properties = $link;
338:
339: $img = new cHTMLImage("images/but_art_conf2.gif");
340: $img->setAlt(i18n("Edit item"));
341: $img->setStyle("padding-right: 4px;");
342: $properties->setContent($img);
343:
344: $actions = $properties->render() . $delete->render();
345:
346: if ($todo->getProperty("todo", "enddate") != "") {
347: $duein = round((time() - strtotime($todo->getProperty("todo", "enddate"))) / 86400, 2);
348: } else {
349: $duein = "";
350: }
351:
352: switch ($priority) {
353: case "low":
354: $p = 0;
355: break;
356: case "medium":
357: $p = 1;
358: break;
359: case "high":
360: $p = 2;
361: break;
362: case "immediately":
363: $p = 3;
364: break;
365: default:
366: break;
367: }
368:
369: $list->setData($lcount, $mimg, $subject, $created, $reminder, $status, $p, $complete, $duein, $actions);
370: $list->setHiddenData($lcount, $idcommunication, $idcommunication);
371:
372: $lcount++;
373: }
374: }
375:
376: $form = new cGuiTableForm("restrict");
377: $form->setTableID("todoList");
378: $form->addHeader(i18n("Restrict display"));
379: $form->setVar("listsubmit", "true");
380:
381: $form->unsetActionButton("submit");
382: $form->setActionButton("submit", "images/but_refresh.gif", i18n("Refresh"), "s");
383:
384: $form->setVar("area", $area);
385: $form->setVar("frame", $frame);
386:
387: $restrict = new cHTMLCheckbox("c_restrict", "true");
388: $restrict->setLabelText(i18n("Hide done tasks"));
389:
390: if ($c_restrict == true) {
391: $restrict->setChecked(true);
392: }
393:
394: $submit = new cHTMLButton("submit");
395: $submit->setMode("image");
396: $submit->setImageSource("images/submit.gif");
397:
398: $form->add(i18n("Options"), $restrict->render());
399:
400: if ($lcount == 0) {
401: $cpage->displayInfo(i18n("No tasks found"));
402: $cpage->setContent(array($form));
403: } else {
404: if (!isset($sortby)) {
405: $sortby = 1;
406: }
407:
408: if (!isset($sortmode)) {
409: $sortmode = "ASC";
410: }
411:
412: $list->setSortable(1, true);
413: $list->setSortable(2, true);
414: $list->setSortable(3, true);
415: $list->setSortable(4, true);
416: $list->setSortable(5, true);
417: $list->setSortable(6, true);
418: $list->setSortable(7, true);
419: $list->sort($sortby, $sortmode);
420:
421: $cpage->setContent(array($form, $list));
422: }
423: $cpage->render();
424:
425: $currentuser->setUserProperty("system", "tasks_sortby", $sortby);
426: $currentuser->setUserProperty("system", "tasks_sortmode", $sortmode);
427:
428: ?>