Пример #1
0
 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     $helper = new helper();
     $projects = new projects();
     $user = new users();
     $tpl->assign('objTickets', $this);
     $tpl->assign('helper', $helper);
     $tpl->assign('allProjects', $projects->getAll());
     $tpl->assign('userProjectrelation', $user->getUserProjectRelation($_SESSION['userdata']['id']));
     $tpl->assign('numText', '');
     //Closed Tickets
     $tpl->assign('allClosedTickets', $this->getUserTickets('0,1', $_SESSION['userdata']['id']));
     //Open Tickets
     $tpl->assign('allOpenTickets', $this->getUserTickets('3,2,4,5,6', $_SESSION['userdata']['id']));
     $tpl->assign('role', $_SESSION['userdata']['role']);
     $tpl->assign('numPages', $this->getNumPages());
     $tpl->display('tickets.showMy');
 }
Пример #2
0
 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     $helper = new helper();
     $projects = new projects();
     //Show closed tickets? (1=yes, 0=no)
     $closedTickets = 1;
     //if(isset($_POST['closedTickets'])===true){
     //$closedTickets = 0;
     //}
     $tpl->assign('closedTickets', $closedTickets);
     $tpl->assign('allTickets', $this->getAllBySearch('', '', $closedTickets));
     $tpl->assign('status', $this->state);
     $tpl->assign('role', $_SESSION['userdata']['role']);
     $tpl->assign('rowsPerPage', $this->rowsPerPage);
     $tpl->assign('objTickets', $this);
     $tpl->assign('helper', $helper);
     $tpl->assign('numPages', $this->getNumPages());
     $tpl->assign('allProjects', $projects->getAll());
     $tpl->display('tickets.showAll');
 }
Пример #3
0
 /**
  * run - display template and edit data
  *
  * @access public
  */
 public function run()
 {
     $tpl = new template();
     $info = '';
     //Only admins and employees
     if ($_SESSION['userdata']['role'] == 'admin' || $_SESSION['userdata']['role'] == 'employee') {
         $projects = new projects();
         $helper = new helper();
         $tickets = new tickets();
         $values = array('userId' => $_SESSION['userdata']['id'], 'ticket' => '', 'project' => '', 'date' => '', 'kind' => '', 'hours' => '', 'description' => '', 'invoicedEmpl' => '', 'invoicedComp' => '', 'invoicedEmplDate' => '', 'invoicedCompDate' => '');
         if (isset($_POST['save']) === true || isset($_POST['saveNew']) === true) {
             if (isset($_POST['tickets']) && $_POST['tickets'] != '') {
                 $temp = $_POST['tickets'];
                 $tempArr = explode('|', $temp);
                 $values['project'] = $tempArr[0];
                 $values['ticket'] = $tempArr[1];
             }
             if (isset($_POST['kind']) && $_POST['kind'] != '') {
                 $values['kind'] = $_POST['kind'];
             }
             if (isset($_POST['date']) && $_POST['date'] != '') {
                 $values['date'] = $helper->timestamp2date($_POST['date'], 4);
             }
             if (isset($_POST['hours']) && $_POST['hours'] != '') {
                 $values['hours'] = $_POST['hours'];
             }
             if (isset($_POST['invoicedEmpl']) && $_POST['invoicedEmpl'] != '') {
                 if ($_POST['invoicedEmpl'] == 'on') {
                     $values['invoicedEmpl'] = 1;
                 }
                 if (isset($_POST['invoicedEmplDate']) && $_POST['invoicedEmplDate'] != '') {
                     $values['invoicedEmplDate'] = $helper->timestamp2date($_POST['invoicedEmplDate'], 4);
                 }
             }
             if (isset($_POST['invoicedComp']) && $_POST['invoicedComp'] != '') {
                 if ($_SESSION['userdata']['role'] == 'admin') {
                     if ($_POST['invoicedComp'] == 'on') {
                         $values['invoicedComp'] = 1;
                     }
                     if (isset($_POST['invoicedCompDate']) && $_POST['invoicedCompDate'] != '') {
                         $values['invoicedCompDate'] = $helper->timestamp2date($_POST['invoicedCompDate'], 4);
                     }
                 }
             }
             if (isset($_POST['description']) && $_POST['description'] != '') {
                 $values['description'] = $_POST['description'];
             }
             if ($values['ticket'] != '' && $values['project'] != '') {
                 if ($values['kind'] != '') {
                     if ($values['date'] != '') {
                         if ($values['hours'] != '' && $values['hours'] > 0) {
                             $this->addTime($values);
                             $info = 'TIME_SAVED';
                         } else {
                             $info = 'NO_HOURS';
                         }
                     } else {
                         $info = 'NO_DATE';
                     }
                 } else {
                     $info = 'NO_KIND';
                 }
             } else {
                 $info = 'NO_TICKET';
             }
             if (isset($_POST['save']) === true) {
                 $values['date'] = $helper->timestamp2date($values['date'], 2);
                 $values['invoicedCompDate'] = $helper->timestamp2date($values['invoicedCompDate'], 2);
                 $values['invoicedEmplDate'] = $helper->timestamp2date($values['invoicedEmplDate'], 2);
                 $tpl->assign('values', $values);
             } elseif (isset($_POST['saveNew']) === true) {
                 $values = array('userId' => $_SESSION['userdata']['id'], 'ticket' => '', 'project' => '', 'date' => '', 'kind' => '', 'hours' => '', 'description' => '', 'invoicedEmpl' => '', 'invoicedComp' => '', 'invoicedEmplDate' => '', 'invoicedCompDate' => '');
                 $tpl->assign('values', $values);
             }
         }
         $tpl->assign('info', $info);
         $tpl->assign('allProjects', $projects->getAll());
         $tpl->assign('allTickets', $tickets->getAll());
         $tpl->assign('kind', $this->kind);
         $tpl->display('timesheets.addTime');
     } else {
         $tpl->display('general.error');
     }
 }
Пример #4
0
 /**
  * @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');
 }
Пример #5
0
 /**
  * run - display template and edit data
  *
  * @access public
  */
 public function run()
 {
     $tpl = new template();
     $info = '';
     //Only admins and employees
     if ($_SESSION['userdata']['role'] == 'admin' || $_SESSION['userdata']['role'] == 'employee') {
         if (isset($_GET['id']) === true) {
             $projects = new projects();
             $helper = new helper();
             $tickets = new tickets();
             $id = $_GET['id'];
             $timesheet = $this->getTimesheet($id);
             $values = array('id' => $id, 'userId' => $timesheet['userId'], 'ticket' => $timesheet['ticketId'], 'project' => $timesheet['projectId'], 'date' => $timesheet['workDate'], 'kind' => $timesheet['kind'], 'hours' => $timesheet['hours'], 'description' => $timesheet['description'], 'invoicedEmpl' => $timesheet['invoicedEmpl'], 'invoicedComp' => $timesheet['invoicedComp'], 'invoicedEmplDate' => $timesheet['invoicedEmplDate'], 'invoicedCompDate' => $timesheet['invoicedCompDate']);
             if ($_SESSION['userdata']['role'] == 'admin' || $_SESSION['userdata']['id'] == $values['userId']) {
                 if (isset($_POST['save']) === true) {
                     if (isset($_POST['tickets']) && $_POST['tickets'] != '') {
                         $temp = $_POST['tickets'];
                         $tempArr = explode('|', $temp);
                         $values['project'] = $tempArr[0];
                         $values['ticket'] = $tempArr[1];
                     }
                     if (isset($_POST['kind']) && $_POST['kind'] != '') {
                         $values['kind'] = $_POST['kind'];
                     }
                     if (isset($_POST['date']) && $_POST['date'] != '') {
                         $dateFormat = $values['date'];
                         $values['date'] = $helper->date2timestamp($_POST['date']);
                         //($helper->timestamp2date($_POST['date'], 4));
                     }
                     if (isset($_POST['hours']) && $_POST['hours'] != '') {
                         $values['hours'] = $_POST['hours'];
                     }
                     if (isset($_POST['description']) && $_POST['description'] != '') {
                         $values['description'] = $_POST['description'];
                     }
                     if (isset($_POST['invoicedEmpl']) && $_POST['invoicedEmpl'] != '') {
                         if ($_POST['invoicedEmpl'] == 'on') {
                             $values['invoicedEmpl'] = 1;
                         }
                         if (isset($_POST['invoicedEmplDate']) && $_POST['invoicedEmplDate'] != '') {
                             $values['invoicedEmplDate'] = $helper->timestamp2date($_POST['invoicedEmplDate'], 4);
                         } else {
                             $values['invoicedEmplDate'] = date("Y-m-d");
                         }
                     } else {
                         $values['invoicedEmpl'] = 0;
                         $values['invoicedEmplDate'] = '';
                     }
                     if ($_SESSION['userdata']['role'] == 'admin') {
                         if (isset($_POST['invoicedComp']) && $_POST['invoicedComp'] != '') {
                             if ($_POST['invoicedComp'] == 'on') {
                                 $values['invoicedComp'] = 1;
                             }
                             if (isset($_POST['invoicedCompDate']) && $_POST['invoicedCompDate'] != '') {
                                 $values['invoicedCompDate'] = $helper->timestamp2date($_POST['invoicedCompDate'], 4);
                             } else {
                                 $values['invoicedCompDate'] = date("Y-m-d");
                             }
                         } else {
                             $values['invoicedComp'] = 0;
                             $values['invoicedCompDate'] = '';
                         }
                     }
                     if ($values['ticket'] != '' && $values['project'] != '') {
                         if ($values['kind'] != '') {
                             if ($values['date'] != '') {
                                 if ($values['hours'] != '' && $values['hours'] > 0) {
                                     $this->updateTime($values);
                                     $tpl->setNotification('SAVE_SUCCESS', 'success');
                                     $values['description'] = $_POST['description'];
                                 } else {
                                     $tpl->setNotification('NO_HOURS', 'error');
                                 }
                             } else {
                                 $tpl->setNotification('NO_DATE', 'error');
                             }
                         } else {
                             $tpl->setNotification('NO_KIND', 'error');
                         }
                     } else {
                         $tpl->setNotification('NO_TICKET', 'error');
                     }
                 }
                 $values['date'] = $helper->timestamp2date($values['date'], 2);
                 $values['invoicedCompDate'] = $helper->timestamp2date($values['invoicedCompDate'], 2);
                 $values['invoicedEmplDate'] = $helper->timestamp2date($values['invoicedEmplDate'], 2);
                 if (isset($dateFormat)) {
                     $values['date'] = $dateFormat;
                 }
                 $tpl->assign('values', $values);
                 $tpl->assign('info', $info);
                 $tpl->assign('allProjects', $projects->getAll());
                 $tpl->assign('allTickets', $tickets->getAll());
                 $tpl->assign('kind', $this->kind);
                 $tpl->display('timesheets.editTime');
             } else {
                 $tpl->display('general.error');
             }
         } else {
             $tpl->display('general.error');
         }
     } else {
         $tpl->display('general.error');
     }
 }
Пример #6
0
 /**
  * run - display template and edit data
  *
  * @access public
  */
 public function run()
 {
     $tpl = new template();
     $invEmplCheck = '0';
     $invCompCheck = '0';
     //Only admins and employees
     if ($_SESSION['userdata']['role'] == 'admin' || $_SESSION['userdata']['role'] == 'employee') {
         $projects = new projects();
         $helper = new helper();
         if ($_SESSION['userdata']['role'] == 'admin') {
             $tpl->assign('admin', true);
         }
         if (isset($_POST['saveInvoice']) === true) {
             $invEmpl = $_POST['invoiced'];
             $this->updateInvoices($invEmpl);
         }
         $projectFilter = '';
         $dateFrom = mktime(0, 0, 0, date("m"), 1, date("Y") - 1);
         $dateFrom = date("Y-m-d", $dateFrom);
         $dateTo = date("Y-m-d 00:00:00");
         $kind = 'all';
         if (isset($_REQUEST['projectFilter']) && $_REQUEST['projectFilter'] != '') {
             $projectFilter = $_REQUEST['projectFilter'];
         }
         if (isset($_REQUEST['kind']) && $_REQUEST['kind'] != '') {
             $kind = $_REQUEST['kind'];
         }
         if (isset($_REQUEST['dateFrom']) && $_REQUEST['dateFrom'] != '') {
             $dateFrom = $helper->timestamp2date($_REQUEST['dateFrom'], 4);
         }
         if (isset($_REQUEST['dateTo']) && $_REQUEST['dateTo'] != '') {
             $dateTo = $helper->timestamp2date($_REQUEST['dateTo'], 4);
         }
         if (isset($_REQUEST['invEmpl']) === true) {
             $invEmplCheck = $_REQUEST['invEmpl'];
             if ($invEmplCheck == 'on') {
                 $invEmplCheck = '1';
             } else {
                 $invEmplCheck = '0';
             }
         } else {
             $invEmplCheck = '0';
         }
         if (isset($_REQUEST['invComp']) === true) {
             $invCompCheck = $_REQUEST['invComp'];
             if ($invCompCheck == 'on') {
                 $invCompCheck = '1';
             } else {
                 $invCompCheck = '0';
             }
         } else {
             $invCompCheck = '0';
         }
         $myTimesheets = $this->getMy($projectFilter, $kind, $dateFrom, $dateTo, $invEmplCheck, $invCompCheck);
         //Is this an export request?
         if (isset($_GET['export']) === true) {
             if ($_GET['export'] == 'excel') {
                 $this->exportExcel($myTimesheets, $dateFrom, $dateTo);
             }
         } else {
             $tpl->assign('dateFrom', $helper->timestamp2date($dateFrom, 2));
             $tpl->assign('dateTo', $helper->timestamp2date($dateTo, 2));
             $tpl->assign('actKind', $kind);
             $tpl->assign('invComp', $invCompCheck);
             $tpl->assign('invEmpl', $invEmplCheck);
             $tpl->assign('kind', $this->kind);
             $tpl->assign('helper', $helper);
             $tpl->assign('projectFilter', $projectFilter);
             $tpl->assign('allProjects', $projects->getAll());
             $tpl->assign('allTimesheets', $myTimesheets);
             $tpl->display('timesheets.showMy');
         }
     } else {
         $tpl->display('general.error');
     }
 }
Пример #7
0
 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     //Only admins
     if ($_SESSION['userdata']['role'] == 'admin') {
         if (isset($_GET['id']) === true) {
             $project = new projects();
             $id = (int) $_GET['id'];
             $row = $this->getUser($id);
             $edit = false;
             $infoKey = '';
             //Build values array
             $values = array('firstname' => $row['firstname'], 'lastname' => $row['lastname'], 'user' => $row['username'], 'phone' => $row['phone'], 'status' => $row['status'], 'role' => $row['role'], 'hours' => $row['hours'], 'wage' => $row['wage'], 'clientId' => $row['clientId']);
             if (isset($_POST['save'])) {
                 $values = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'user' => $_POST['user'], 'phone' => $_POST['phone'], 'status' => $_POST['status'], 'role' => $_POST['role'], 'hours' => $_POST['hours'], 'wage' => $_POST['wage'], 'clientId' => $_POST['client']);
                 $changedEmail = 0;
                 if ($row['username'] != $values['user']) {
                     $changedEmail = 1;
                 }
                 if ($values['user'] !== '') {
                     $helper = new helper();
                     if ($helper->validateEmail($values['user']) === 1) {
                         if ($changedEmail == 1) {
                             if ($this->usernameExist($row['username'], $id) === false) {
                                 $edit = true;
                             } else {
                                 $tpl->setNotification('USERNAME_EXISTS', 'error');
                             }
                         } else {
                             $edit = true;
                         }
                     } else {
                         $tpl->setNotification('NO_VALID_EMAIL_' . $helper->validateEmail($values['user']), 'error');
                     }
                 } else {
                     $tpl->setNotification('NO_USERNAME', 'error');
                 }
             }
             //Was everything okay?
             if ($edit !== false) {
                 $this->editUser($values, $id);
                 if (isset($_POST['projects'])) {
                     if ($_POST['projects'][0] !== '0') {
                         $project->editUserProjectRelations($id, $_POST['projects']);
                     } else {
                         $project->deleteAllProjectRelations($id);
                     }
                 }
                 $tpl->setNotification('EDIT_SUCCESS', 'success');
             }
             // Get relations to projects
             $projects = $project->getUserProjectRelation($id);
             $projectrelation = array();
             foreach ($projects as $projectId) {
                 $projectrelation[] = $projectId['projectId'];
             }
             //Assign vars
             $clients = new clients();
             $tpl->assign('clients', $clients->getAll());
             $tpl->assign('allProjects', $project->getAll());
             $tpl->assign('values', $values);
             $tpl->assign('relations', $projectrelation);
             $tpl->assign('roles', $this->getRoles());
             $tpl->assign('status', $this->status);
             $tpl->display('users.editUser');
         } else {
             $tpl->display('general.error');
         }
     } else {
         $tpl->display('general.error');
     }
 }
Пример #8
0
 /**
  * run - display template and edit data
  *
  * @access public
  */
 public function run()
 {
     $tpl = new template();
     //Only admins and employees
     $projects = new projects();
     $helper = new helper();
     if ($_SESSION['userdata']['role'] == 'admin') {
     }
     if (isset($_POST['saveInvoice']) === true) {
         $invEmpl = '';
         $invComp = '';
         if (isset($_POST['invoicedEmpl']) === true) {
             $invEmpl = $_POST['invoicedEmpl'];
         }
         if (isset($_POST['invoicedComp']) === true) {
             $invComp = $_POST['invoicedComp'];
         }
         $this->updateInvoices($invEmpl, $invComp);
     }
     $invEmplCheck = '0';
     $invCompCheck = '0';
     $projectFilter = '';
     $dateFrom = mktime(0, 0, 0, date("m"), '1', date("Y"));
     $dateTo = mktime(0, 0, 0, date("m"), date("t"), date("Y"));
     $dateFrom = date("Y-m-d", $dateFrom);
     $dateTo = date("Y-m-d 00:00:00", $dateTo);
     $kind = 'all';
     $userId = 'all';
     if (isset($_POST['projectFilter']) && $_POST['projectFilter'] != '') {
         $projectFilter = $_POST['projectFilter'];
     }
     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';
     }
     if (isset($_POST['export'])) {
         $values = array('project' => $projectFilter, 'kind' => $kind, 'userId' => $userId, 'dateFrom' => $dateFrom, 'dateTo' => $dateTo, 'invEmplCheck' => $invEmplCheck, 'invCompCheck' => $invCompCheck);
         $this->export($values);
     }
     $user = new users();
     $employees = $user->getEmployees();
     $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', $this->kind);
     $tpl->assign('invComp', $invCompCheck);
     $tpl->assign('invEmpl', $invEmplCheck);
     $tpl->assign('helper', $helper);
     $tpl->assign('projectFilter', $projectFilter);
     $tpl->assign('allProjects', $projects->getAll());
     $tpl->assign('allTimesheets', $this->getAll($projectFilter, $kind, $dateFrom, $dateTo, $userId, $invEmplCheck, $invCompCheck));
     $tpl->display('timesheets.showAll');
 }