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