コード例 #1
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');
     }
 }
コード例 #2
0
ファイル: class.show.php プロジェクト: DevelopIdeas/leantime
 /**
  * @return unknown_type
  */
 public function run()
 {
     $tpl = new template();
     $helper = new helper();
     if (!$this->userHasWidgets($_SESSION['userdata']['id'])) {
         $this->setDefaultWidgets($_SESSION['userdata']['id']);
     }
     // CALENDAR
     $calendar = new calendar();
     $tpl->assign('calendar', $calendar->getCalendar($_SESSION['userdata']['id']));
     // TICKETS
     $tickets = new tickets();
     $tpl->assign('myTickets', $tickets->getUserTickets(3, $_SESSION['userdata']['id']));
     // PROJECTS
     $projects = new projects();
     $allProjects = $projects->getAll(false, 5);
     $myProjects = array();
     foreach ($allProjects as $project) {
         $opentickets = $projects->getOpenTickets($project['id']);
         $closedTickets = $project['numberOfTickets'] - $opentickets['openTickets'];
         if ($project['numberOfTickets'] != 0) {
             $projectPercentage = round($closedTickets / $project['numberOfTickets'] * 100, 2);
         } else {
             $projectPercentage = 0;
         }
         $values = array('id' => $project['id'], 'name' => $project['name'], 'projectPercentage' => $projectPercentage);
         $myProjects[] = $values;
     }
     // HOURS
     $ts = new timesheets();
     $myHours = $ts->getUsersHours($_SESSION['userdata']['id']);
     $tpl->assign('myHours', $myHours);
     // NOTES
     if (isset($_POST['save'])) {
         if (isset($_POST['title']) && isset($_POST['description'])) {
             $values = array('title' => $_POST['title'], 'description' => $_POST['description']);
             $this->addNote($_SESSION['userdata']['id'], $values);
             $tpl->setNotification('SAVE_SUCCESS', 'success');
         } else {
             $tpl->setNotification('MISSING_FIELDS', 'error');
         }
     }
     // Statistics
     $tpl->assign('closedTicketsPerWeek', $this->getClosedTicketsPerWeek());
     $tpl->assign('hoursPerTicket', round($this->getHoursPerTicket()));
     $tpl->assign('hoursBugFixing', round($this->getHoursBugFixing(), 1));
     // WIDGET CUSTOMIZATION
     if (isset($_POST['updateWidgets'])) {
         $widgets = array();
         foreach ($this->getWidgets() as $widget) {
             if (isset($_POST['widget-' . $widget['id']])) {
                 $widgets[] = $widget['id'];
             }
         }
         if (count($widgets)) {
             $this->updateWidgets($_SESSION['userdata']['id'], $widgets);
             $tpl->setNotification('SAVE_SUCCESS', 'success');
         } else {
             $tpl->setNotification('ONE_WIDGET_REQUIRED', 'error');
         }
     }
     // HOT LEADS
     $leads = new leads();
     $hotLeads = $leads->getHotLeads();
     $tpl->assign('hotLeads', $hotLeads);
     $tpl->assign('notes', $this->getNotes($_SESSION['userdata']['id']));
     $tpl->assign('availableWidgets', $this->getAvailableWidgets($_SESSION['userdata']['id']));
     $tpl->assign('myProjects', $myProjects);
     $tpl->assign('widgetTypes', $this->getWidgets());
     $tpl->assign('widgets', $this->getUsersWidgets($_SESSION['userdata']['id']));
     $tpl->assign('helper', $helper);
     $tpl->display('dashboard.show');
 }
コード例 #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');
     }
 }