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: if ($amount != 0) {
132: $image = new cHTMLImage($backendUrl . $cfg["path"]["images"] . "reminder/progress.gif");
133: $image->setAlt(sprintf(i18n("%d %% complete"), $value));
134: $ret = "";
135:
136: for ($i = 0; $i < $amount; $i++) {
137: $ret .= $image->render();
138: }
139:
140: return $ret;
141: } else {
142: return ' ';
143: }
144: }
145:
146: if ($key == 6) {
147: switch ($value) {
148: case 0:
149: $img = "prio_low.gif";
150: $p = "low";
151: break;
152: case 1:
153: $img = "prio_medium.gif";
154: $p = "medium";
155: break;
156: case 2:
157: $img = "prio_high.gif";
158: $p = "high";
159: break;
160: case 3:
161: $img = "prio_veryhigh.gif";
162: $p = "immediately";
163: break;
164: default:
165: break;
166: }
167:
168: $image = new cHTMLImage($backendUrl . $cfg["path"]["images"] . "reminder/" . $img);
169: $image->setAlt($this->prioritytypes[$p]);
170: return $image->render();
171: }
172:
173: if ($key == 8) {
174:
175: if ($value !== "") {
176: if (round($value, 2) == 0) {
177: return i18n("Today");
178: } else {
179: if ($value < 0) {
180: return number_format(0 - $value, 2, ',', '') . " " . i18n("Day(s)");
181: } else {
182: return '<font color="red">' . number_format(0 - $value, 2, ',', '') . " " . i18n("Day(s)") . '</font>';
183: }
184: }
185: } else {
186: return ' ';
187: }
188: }
189:
190: return $value;
191: }
192:
193: }
194:
195: if ($action == "todo_save_item") {
196: $subject = stripslashes($subject);
197: $message = stripslashes($message);
198:
199: $todoitem = new TODOItem();
200: $todoitem->loadByPrimaryKey($idcommunication);
201:
202: $todoitem->set("subject", $subject);
203: $todoitem->set("message", $message);
204: $todoitem->set("recipient", $userassignment);
205:
206: if (isset($reminderdate)) {
207: $todoitem->setProperty("todo", "reminderdate", strtotime($reminderdate));
208: }
209:
210: if (isset($notibackend)) {
211: $todoitem->setProperty("todo", "backendnoti", $notibackend);
212: }
213:
214: $todoitem->setProperty("todo", "emailnoti", $notiemail);
215:
216: $todoitem->setProperty("todo", "status", $status);
217:
218: if ($progress < 0) {
219: $progress = 0;
220: }
221:
222: if ($progress > 100) {
223: $progress = 100;
224: }
225:
226: $todoitem->setProperty("todo", "priority", $priority);
227: $todoitem->setProperty("todo", "progress", $progress);
228:
229: $todoitem->setProperty("todo", "enddate", $enddate);
230:
231: $todoitem->store();
232: }
233:
234: $cpage = new cGuiPage("mycontenido.tasks", "", "1");
235:
236: $todoitems = new TODOCollection();
237:
238: if ($action == "mycontenido_tasks_delete") {
239: $todoitems->delete($idcommunication);
240: }
241:
242: $recipient = $auth->auth["uid"];
243:
244: $todoitems->select("recipient = '" . $todoitems->escape($recipient) . "' AND idclient=" . (int) $client);
245:
246: $list = new TODOBackendList();
247:
248: $list->setHeader(
249: ' ', i18n("Subject"), i18n("Created"), i18n("End Date"), i18n("Status"),
250: i18n("Priority"), sprintf(i18n("%% complete")), i18n("Due in"), i18n("Actions")
251: );
252:
253: $lcount = 0;
254:
255: $link = new cHTMLLink();
256: $link->setCLink("mycontenido_tasks_edit", 4, "");
257: $link->setCustom("sortmode", $sortmode);
258: $link->setCustom("sortby", $sortby);
259:
260: while ($todo = $todoitems->next()) {
261: if ((($todo->getProperty("todo", "status") != "done") && ($c_restrict == true)) || ($c_restrict == '')) {
262:
263: $subject = $todo->get("subject");
264: $created = $todo->get("created");
265:
266: $reminder = $todo->getProperty("todo", "enddate");
267: $status = $todo->getProperty("todo", "status");
268: $priority = $todo->getProperty("todo", "priority");
269: $complete = $todo->getProperty("todo", "progress");
270:
271: if (trim($subject) == "") {
272: $subject = i18n("Unnamed item");
273: }
274:
275: if (trim($reminder) == "") {
276: $reminder = i18n("No end date set");
277: } else {
278: $reminder = date($dateformat, strtotime($reminder));
279: }
280:
281: if (trim($status) == "") {
282: $status = i18n("No status set");
283: }
284:
285: $link->setCustom("idcommunication", $todo->get("idcommunication"));
286: $link->setContent('<img id="myContenidoTodoButton" src="images/but_todo.gif" border="0">');
287:
288: $mimg = $link->render();
289:
290: $link->setContent($subject);
291:
292: $msubject = $link->render();
293:
294: $idcommunication = $todo->get("idcommunication");
295:
296: $delete = new cHTMLLink();
297: $delete->setCLink("mycontenido_tasks", 4, "mycontenido_tasks_delete");
298: $delete->setCustom("idcommunication", $idcommunication);
299: $delete->setCustom("sortby", $sortby);
300: $delete->setCustom("sortmode", $sortmode);
301:
302: $img = new cHTMLImage("images/delete.gif");
303: $img->setAlt(i18n("Delete item"));
304:
305: $delete->setContent($img->render());
306:
307: $properties = $link;
308:
309: $img = new cHTMLImage("images/but_art_conf2.gif");
310: $img->setAlt(i18n("Edit item"));
311: $img->setStyle("padding-right: 4px;");
312: $properties->setContent($img);
313:
314: $actions = $properties->render() . $delete->render();
315:
316: if ($todo->getProperty("todo", "enddate") != "") {
317: $duein = round((time() - strtotime($todo->getProperty("todo", "enddate"))) / 86400, 2);
318: } else {
319: $duein = "";
320: }
321:
322: switch ($priority) {
323: case "low":
324: $p = 0;
325: break;
326: case "medium":
327: $p = 1;
328: break;
329: case "high":
330: $p = 2;
331: break;
332: case "immediately":
333: $p = 3;
334: break;
335: default:
336: break;
337: }
338:
339: $list->setData($lcount, $mimg, $subject, $created, $reminder, $status, $p, $complete, $duein, $actions);
340: $list->setHiddenData($lcount, $idcommunication, $idcommunication);
341:
342: $lcount++;
343: }
344: }
345:
346: $form = new cGuiTableForm("restrict");
347: $form->setTableID("todoList");
348: $form->addHeader(i18n("Restrict display"));
349: $form->setVar("listsubmit", "true");
350:
351: $form->unsetActionButton("submit");
352: $form->setActionButton("submit", "images/but_refresh.gif", i18n("Refresh"), "s");
353:
354: $form->setVar("area", $area);
355: $form->setVar("frame", $frame);
356:
357: $restrict = new cHTMLCheckbox("c_restrict", "true");
358: $restrict->setLabelText(i18n("Hide done tasks"));
359:
360: if ($c_restrict == true) {
361: $restrict->setChecked(true);
362: }
363:
364: $submit = new cHTMLButton("submit");
365: $submit->setMode("image");
366: $submit->setImageSource("images/submit.gif");
367:
368: $form->add(i18n("Options"), $restrict->render());
369:
370: if ($lcount == 0) {
371: $cpage->displayInfo(i18n("No tasks found"));
372: $cpage->setContent(array($form));
373: } else {
374: if (!isset($sortby)) {
375: $sortby = 1;
376: }
377:
378: if (!isset($sortmode)) {
379: $sortmode = "ASC";
380: }
381:
382: $list->setSortable(1, true);
383: $list->setSortable(2, true);
384: $list->setSortable(3, true);
385: $list->setSortable(4, true);
386: $list->setSortable(5, true);
387: $list->setSortable(6, true);
388: $list->setSortable(7, true);
389: $list->sort($sortby, $sortmode);
390:
391: $cpage->setContent(array($form, $list));
392: }
393: $cpage->render();
394:
395: $currentuser->setUserProperty("system", "tasks_sortby", $sortby);
396: $currentuser->setUserProperty("system", "tasks_sortmode", $sortmode);
397:
398: ?>