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