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