Ejemplo n.º 1
0
 private function getCommentList(comments $tree, $parent_id, $TEMPLATE)
 {
     $all_count = $tree->countComments($parent_id);
     $list = '';
     $num = 0;
     while ($comment = $tree->getComment($parent_id)) {
         $sub_comments = $tree->issetComments($parent_id) ? $this->getCommentList($tree, $comment->id(), $TEMPLATE) : '';
         $num++;
         page::assign('obj.num', $num);
         page::assign('class-first', $num == 1 ? 'first' : '');
         page::assign('class-last', $num == $all_count ? 'last' : '');
         page::assign('class-odd', $num % 2 == 0 ? 'odd' : '');
         page::assign('class-even', $num % 2 != 0 ? 'even' : '');
         page::assign('class-third', $num % 3 == 0 ? 'third' : '');
         page::assign('obj.id', $comment->id());
         page::assign('obj.parent_id', $comment->getParentId());
         page::assign('obj.user_id', $comment->getUserId());
         page::assign('obj.publ_date', $comment->getPublDate());
         page::assign('obj.username', $comment->getUserName());
         page::assign('obj.email', $comment->getEmail());
         page::assign('obj.text', $comment->getText());
         page::assign('obj.rate', $comment->getRate());
         if (isset($_SESSION['comments_rate'][$comment->id()])) {
             page::fParse('rate', $TEMPLATE['rate_change']);
         } else {
             page::fParse('rate', $TEMPLATE['rate']);
         }
         if (!empty($sub_comments)) {
             page::assign('list', $sub_comments);
             page::fParse('list', $TEMPLATE['frame_list']);
         } else {
             page::assign('list', '');
         }
         $list .= page::parse($TEMPLATE['list']);
     }
     return $list;
 }
Ejemplo n.º 2
0
 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     if (isset($_GET['id'])) {
         $id = (int) $_GET['id'];
         $project = $this->getProject($id);
         $helper = new helper();
         $language = new language();
         $language->setModule('projects');
         $lang = $language->readIni();
         //Calculate projectdetails
         $opentickets = $this->getOpenTickets($id);
         $closedTickets = $project['numberOfTickets'] - $opentickets['openTickets'];
         if ($project['numberOfTickets'] != 0) {
             $projectPercentage = round($closedTickets / $project['numberOfTickets'] * 100, 2);
         } else {
             $projectPercentage = 0;
         }
         if ($project['numberOfTickets'] == NULL) {
             $project['numberOfTickets'] = 1;
         }
         //Post comment
         $comments = new comments();
         if (isset($_POST['comment']) === true) {
             $values = array('text' => $_POST['text'], 'datetime' => date("Y-m-d H:i:s"), 'userId' => $_SESSION['userdata']['id'], 'moduleId' => $id, 'commentParent' => $_POST['father']);
             $comments->addComment($values, 'project');
             $tpl->setNotification('COMMENT_ADDED', 'success');
         }
         $file = new files();
         if (isset($_POST['upload'])) {
             if (isset($_FILES['file'])) {
                 $file->upload($_FILES, 'project', $id);
                 $tpl->setNotification('FILE_UPLOADED', 'success');
             } else {
                 $tpl->setNotification('NO_FILE', 'error');
             }
         }
         $timesheets = new timesheets();
         $language = new language();
         $language->setModule('projects');
         $lang = $language->readIni();
         $data = array();
         $months = array();
         $results = $timesheets->getProjectHours($id);
         $allHours = 0;
         $max = 0;
         foreach ($results as $row) {
             if ($row['month'] != NULL) {
                 $data[] = (int) $row['summe'];
                 $months[] = substr($language->lang_echo('MONTH_' . $row['month'] . ''), 0, 3);
                 if ($row['summe'] > $max) {
                     $max = $row['summe'];
                 }
             } else {
                 $allHours = $row['summe'];
             }
         }
         $steps = 10;
         if ($max > 100) {
             $steps = 50;
         }
         $max = $max + $steps;
         $tpl->assign('timesheetsAllHours', $allHours);
         $chart = "";
         $tpl->assign('chart', $chart);
         //Delete File
         if (isset($_GET['delFile']) === true) {
             $file = $_GET['delFile'];
             $upload = new fileupload();
             $upload->initFile($file);
             $upload->deleteFile($file);
             $this->deleteFile($file);
             $this->setNotification('FILE_DELETED', 'success');
         }
         //Delete comment
         if (isset($_GET['delComment']) === true) {
             $commentId = (int) $_GET['delComment'];
             $this->deleteComment($commentId);
             $this->setNotification('COMMENT_DELETED');
         }
         //Delete account
         if (isset($_GET['delAccount']) === true) {
             $accountId = (int) $_GET['delAccount'];
             $this->deleteAccount($accountId);
             $this->setNotification('ACCOUNT_DELETED');
         }
         //Timesheets
         $invEmplCheck = '0';
         $invCompCheck = '0';
         $projectFilter = $id;
         $dateFrom = mktime(0, 0, 0, date("m"), '1', date("Y"));
         $dateFrom = date("Y-m-d", $dateFrom);
         $dateTo = date("Y-m-d 00:00:00");
         $kind = 'all';
         $userId = 'all';
         if (isset($_POST['kind']) && $_POST['kind'] != '') {
             $kind = $_POST['kind'];
         }
         if (isset($_POST['userId']) && $_POST['userId'] != '') {
             $userId = $_POST['userId'];
         }
         if (isset($_POST['dateFrom']) && $_POST['dateFrom'] != '') {
             $dateFrom = $helper->timestamp2date($_POST['dateFrom'], 4);
         }
         if (isset($_POST['dateTo']) && $_POST['dateTo'] != '') {
             $dateTo = $helper->timestamp2date($_POST['dateTo'], 4);
         }
         if (isset($_POST['invEmpl']) === true) {
             $invEmplCheck = $_POST['invEmpl'];
             if ($invEmplCheck == 'on') {
                 $invEmplCheck = '1';
             } else {
                 $invEmplCheck = '0';
             }
         } else {
             $invEmplCheck = '0';
         }
         if (isset($_POST['invComp']) === true) {
             $invCompCheck = $_POST['invComp'];
             if ($invCompCheck == 'on') {
                 $invCompCheck = '1';
             } else {
                 $invCompCheck = '0';
             }
         } else {
             $invCompCheck = '0';
         }
         $user = new users();
         $employees = $user->getEmployees();
         $timesheets = new timesheets();
         $projects = new projects();
         $tpl->assign('employeeFilter', $userId);
         $tpl->assign('employees', $employees);
         $tpl->assign('dateFrom', $helper->timestamp2date($dateFrom, 2));
         $tpl->assign('dateTo', $helper->timestamp2date($dateTo, 2));
         $tpl->assign('actKind', $kind);
         $tpl->assign('kind', $timesheets->kind);
         $tpl->assign('invComp', $invCompCheck);
         $tpl->assign('invEmpl', $invEmplCheck);
         $tpl->assign('helper', $helper);
         $tpl->assign('projectFilter', $projectFilter);
         $tpl->assign('allTimesheets', $timesheets->getAll($projectFilter, $kind, $dateFrom, $dateTo, $userId, $invEmplCheck, $invCompCheck));
         /* 			'name' = :name AND
         						'username' = :username AND
         						'password' = :password AND
         						'host' = :host AND
         						'kind' = :kind */
         if (isset($_POST['accountSubmit'])) {
             $values = array('name' => $_POST['accountName'], 'username' => $_POST['username'], 'password' => $_POST['password'], 'host' => $_POST['host'], 'kind' => $_POST['kind']);
             $this->addAccount($values, $id);
         }
         //Assign vars
         $ticket = new tickets();
         $tpl->assign('imgExtensions', array('jpg', 'jpeg', 'png', 'gif', 'psd', 'bmp', 'tif', 'thm', 'yuv'));
         $tpl->assign('projectTickets', $this->getProjectTickets($id));
         $tpl->assign('projectPercentage', $projectPercentage);
         $tpl->assign('openTickets', $opentickets['openTickets']);
         $tpl->assign('project', $project);
         $files = $file->getFilesByModule('project', $id);
         $tpl->assign('files', $files);
         $tpl->assign('numFiles', count($files));
         $bookedHours = $this->getProjectBookedHours($id);
         if ($bookedHours['totalHours'] != '') {
             $booked = round($bookedHours['totalHours'], 3);
         } else {
             $booked = 0;
         }
         $tpl->assign('bookedHours', $booked);
         $bookedDollars = $this->getProjectBookedDollars($id);
         if ($bookedDollars['totalDollars'] != '') {
             $dollars = round($bookedDollars['totalDollars'], 3);
         } else {
             $dollars = 0;
         }
         $tpl->assign('bookedDollars', $dollars);
         $tpl->assign("bookedHoursArray", $this->getProjectBookedHoursArray($id));
         //			die($id);
         $comment = $comments->getComments('project', $_GET['id']);
         $tpl->assign('comments', $comment);
         $tpl->assign('numComments', $comments->countComments('project', $_GET['id']));
         $tpl->assign('state', $this->state);
         $tpl->assign('helper', $helper);
         $tpl->assign('role', $_SESSION['userdata']['role']);
         $accounts = $this->getProjectAccounts($id);
         $tpl->assign('accounts', $accounts);
         $tpl->display('projects.showProject');
     } else {
         $tpl->display('general.error');
     }
 }
Ejemplo n.º 3
0
 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     $msgKey = '';
     if (isset($_GET['id']) === true) {
         $id = (int) $_GET['id'];
         $ticket = $this->getTicket($id);
         $editable = true;
         if (!empty($ticket)) {
             $helper = new helper();
             $file = new files();
             $user = new users();
             $comment = new comments();
             // Has the user seen this ticket already
             $read = new read();
             if (!$read->isRead('ticket', $id, $_SESSION['userdata']['id'])) {
                 $read->markAsRead('ticket', $id, $_SESSION['userdata']['id']);
             }
             //TODO New access right management...This is dumb
             if ($ticket['userId'] == $_SESSION['userdata']['id'] || $ticket['editorId'] == $_SESSION['userdata']['id'] || $ticket['editorId'] == '') {
                 $editable = true;
             }
             //Punch times
             if (isset($_POST['punchIn']) && $this->isClocked($_SESSION['userdata']['id']) != true) {
                 $this->punchIn($ticket['id']);
             } else {
                 if (isset($_POST['punchOut']) && $this->isClocked($_SESSION['userdata']['id']) == true) {
                     $this->punchOut($ticket['id']);
                 }
             }
             //Upload File
             if (isset($_POST['upload'])) {
                 if (isset($_FILES['file'])) {
                     if ($file->upload($_FILES, 'ticket', $id) !== false) {
                         $tpl->setNotification('FILE_UPLOADED', 'success');
                     } else {
                         $tpl->setNotification('ERROR_WHILE_UPLOADING', 'error');
                     }
                 } else {
                     $tpl->setNotification('NO_FILE', 'error');
                 }
             }
             //Add comment
             if (isset($_POST['comment']) === true) {
                 $mail = new mailer();
                 $values = array('text' => $_POST['text'], 'date' => date("Y-m-d H:i:s"), 'userId' => $_SESSION['userdata']['id'], 'moduleId' => $id, 'commentParent' => $_POST['father']);
                 $comment->addComment($values, 'ticket');
                 $tpl->setNotification('COMMENT_ADDED', 'success');
             }
             //Only admins
             if ($_SESSION['userdata']['role'] == 'admin') {
                 $editable = true;
                 //Delete file
                 if (isset($_GET['delFile']) === true) {
                     $file = $_GET['delFile'];
                     $upload = new fileupload();
                     $upload->initFile($file);
                     //Delete file from server
                     $upload->deleteFile($file);
                     //Delete file from db
                     $this->deleteFile($file);
                     $msgKey = 'FILE_DELETED';
                 }
                 //Delete comment
                 if (isset($_GET['delComment']) === true) {
                     $commentId = (int) $_GET['delComment'];
                     $comment->deleteComment($commentId);
                     $msgKey = 'COMMENT_DELETED';
                 }
             }
             $allHours = 0;
             $values = array('userId' => $_SESSION['userdata']['id'], 'ticket' => $id, 'date' => '', 'kind' => '', 'hours' => '', 'description' => '', 'invoicedEmpl' => '', 'invoicedComp' => '', 'invoicedEmplDate' => '', 'invoicedCompDate' => '');
             $timesheets = new timesheets();
             $ticketHours = $timesheets->getTicketHours($id);
             $tpl->assign('ticketHours', $ticketHours);
             $tpl->assign('userHours', $timesheets->getUsersTicketHours($id, $_SESSION['userdata']['id']));
             $userinfo = $user->getUser($values['userId']);
             $tpl->assign('kind', $timesheets->kind);
             $tpl->assign('userInfo', $userinfo);
             if (isset($_POST['saveTimes']) === true) {
                 if (isset($_POST['kind']) && $_POST['kind'] != '') {
                     $values['kind'] = $_POST['kind'];
                 }
                 if (isset($_POST['date']) && $_POST['date'] != '') {
                     $date = $helper->date2timestamp($_POST['date']);
                     //die($date);
                     //$values['date'] = ($helper->timestamp2date($date, 4));
                     $values['date'] = $date;
                 }
                 $values['rate'] = $userinfo['wage'];
                 if (isset($_POST['hours']) && $_POST['hours'] != '') {
                     $values['hours'] = $_POST['hours'];
                 }
                 if (isset($_POST['description']) && $_POST['description'] != '') {
                     $values['description'] = $_POST['description'];
                 }
                 if ($values['kind'] != '') {
                     if ($values['date'] != '') {
                         if ($values['hours'] != '' && $values['hours'] > 0) {
                             $timesheets->addTime($values);
                             $tpl->setNotification('TIME_SAVED', 'success');
                         } else {
                             $tpl->setNotification('NO_HOURS', 'success');
                         }
                     } else {
                         $tpl->setNotification('NO_DATE', 'error');
                     }
                 } else {
                     $tpl->setNotification('NO_KIND', 'success');
                 }
                 $tpl->assign('userId', $values['userId']);
             }
             $timesheets = new timesheets();
             $language = new language();
             $language->setModule('tickets');
             $lang = $language->readIni();
             $data = array();
             $data2 = array();
             $months = array();
             $results = $timesheets->getTicketHours($id);
             $allHours = 0;
             foreach ($results as $row) {
                 if ($row['summe']) {
                     $allHours += $row['summe'];
                 }
             }
             $tpl->assign('timesheetsAllHours', $allHours);
             $remainingHours = $ticket['planHours'] - $allHours;
             $comments = $comment->getComments('ticket', $ticket['id']);
             $files = $file->getFilesByModule('ticket', $id);
             $unreadCount = count($this->getUnreadTickets($_SESSION['userdata']['id']));
             $tpl->assign('unreadCount', $unreadCount);
             $tpl->assign('imgExtensions', array('jpg', 'jpeg', 'png', 'gif', 'psd', 'bmp', 'tif', 'thm', 'yuv'));
             $tpl->assign('ticketHistory', $this->getTicketHistory((int) $_GET['id']));
             $tpl->assign('remainingHours', $remainingHours);
             $tpl->assign('ticketPrice', $this->getTicketCost($_GET['id']));
             $tpl->assign('info', $msgKey);
             $tpl->assign('role', $_SESSION['userdata']['role']);
             $tpl->assign('ticket', $ticket);
             $tpl->assign('objTicket', $this);
             $tpl->assign('state', $this->state);
             $tpl->assign('statePlain', $this->statePlain);
             $tpl->assign('numComments', $comment->countComments('ticket', $ticket['id']));
             $tpl->assign('comments', $comments);
             $tpl->assign('editable', $editable);
             $tpl->assign('files', $files);
             $tpl->assign('numFiles', count($files));
             $tpl->assign('helper', $helper);
             $tpl->display('tickets.showTicket');
         } else {
             $tpl->display('general.error');
         }
     } else {
         $tpl->display('general.error');
     }
 }