<?php $sum = 0; foreach ($this->get('allTimesheets') as $row) { $sum = $sum + $row['hours']; ?> <tr> <td><a href="index.php?act=timesheets.editTime&id=<?php echo $row['id']; ?> "><?php echo $row['id']; ?> </a></td> <td><?php echo $helper->timestamp2date($row['workDate'], 2); ?> </td> <td><?php echo $row['hours']; ?> </td> <td><?php echo $row['planHours']; ?> </td> <?php $diff = $row['planHours'] - $row['hours']; ?> <td <?php if ($diff < 0) {
if (count($message->getMessageChain($msgList['id'], $msgList['parent_id'])) > 1) { foreach ($message->getMessageChain($msgList['id'], $msgList['parent_id']) as $reply) { ?> <div class='msgauthor' onclick='toggleMsgBody(<?php echo $reply['id']; ?> ,"inbox")'> <div class="thumb"><img src='<?php echo $user->getProfilePicture($reply['fromUserId']); ?> ' /></div> <div class="authorinfo"> <span class="date pull-right"> <?php echo $helper->timestamp2date($reply['date_sent'], 3); ?> <br /><br /> <span class='caret f-right'></span> </span> <h5> <strong><?php echo $reply['fromFirstname'] . ' ' . $reply['fromLastname']; ?> </strong> <span><?php echo $reply['fromUsername']; ?> </span> </h5> <span class="to">to <?php
echo $ticket['projectName']; ?> </td> <td><?php echo $ticket['clientName']; ?> </td> <td><?php echo $ticket['editorFirstname']; ?> <?php echo $ticket['editorLastname']; ?> </td> <td><?php echo $helper->timestamp2date($ticket['date'], 2); ?> </td> <td><?php echo $helper->timestamp2date($ticket['dateToFinish'], 2); ?> </td> <td><?php echo $helper->timestamp2date($ticket['editFrom'], 2); ?> - <?php echo $helper->timestamp2date($ticket['editTo'], 2); ?> </td> <td><?php
/** * 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'); } }
/** * run - display template and edit data * * @access public * */ public function run() { $tpl = new template(); $helper = new helper(); $projectObj = new projects(); $user = new users(); $language = new language(); $language->setModule('tickets'); $lang = $language->readIni(); $projects = $projectObj->getUserProjects("open"); $msgKey = ''; if (isset($_POST['save'])) { $values = array('headline' => $_POST['headline'], 'type' => $_POST['type'], 'description' => $_POST['description'], 'priority' => $_POST['priority'], 'projectId' => $_POST['project'], 'editorId' => implode(',', $_POST['editorId']), 'userId' => $_SESSION['userdata']['id'], 'date' => $helper->timestamp2date(date("Y-m-d H:i:s"), 2), 'dateToFinish' => $_POST['dateToFinish'], 'status' => 3, 'browser' => $_POST['browser'], 'os' => $_POST['os'], 'resolution' => $_POST['resolution'], 'version' => $_POST['version'], 'url' => $_POST['url'], 'editFrom' => $_POST['editFrom'], 'editTo' => $_POST['editTo']); if ($values['headline'] === '') { $tpl->setNotification('ERROR_NO_HEADLINE', 'error'); } elseif ($values['description'] === '') { $tpl->setNotification('ERROR_NO_DESCRIPTION', 'error'); } elseif ($values['projectId'] === '') { $tpl->setNotification('ERROR_NO_PROJECT', 'error'); } else { $values['date'] = $helper->timestamp2date($values['date'], 4); $values['dateToFinish'] = $helper->timestamp2date($values['dateToFinish'], 4); $values['editFrom'] = $helper->timestamp2date($values['editFrom'], 4); $values['editTo'] = $helper->timestamp2date($values['editTo'], 4); // returns last inserted id $id = $this->addTicket($values); //Take the old value to avoid nl character $values['description'] = $_POST['description']; $values['date'] = $helper->timestamp2date($values['date'], 2); $values['dateToFinish'] = $helper->timestamp2date($values['dateToFinish'], 2); $values['editFrom'] = $helper->timestamp2date($values['editFrom'], 2); $values['editTo'] = $helper->timestamp2date($values['editTo'], 2); $msgKey = 'TICKET_ADDED'; $tpl->setNotification('TICKET_ADDED', 'success'); //Fileupload if (htmlspecialchars($_FILES['file']['name']) != '') { $upload = new fileupload(); $upload->initFile($_FILES['file']); if ($upload->error == '') { // hash name on server for security reasons $newname = md5($id . time()); //Encrypt filename on server $upload->renameFile($newname); if ($upload->upload() === true) { $fileValues = array('encName' => $upload->file_name, 'realName' => $upload->real_name, 'date' => date("Y-m-d H:i:s"), 'ticketId' => $id, 'userId' => $_SESSION['userdata']['id']); $this->addFile($fileValues); } else { $msgKey = 'ERROR_FILEUPLOAD_' . $upload->error . ''; } } else { $msgKey = 'ERROR_FILEUPLOAD_' . $upload->error . ''; } } /* //Send mail $mail = new mailer(); $row = $projectObj->getProject($values['projectId']); $mail->setSubject(''.$lang['ZYPRO_NEW_TICKET'].' "'.$row['name'].'" '); $username = $user->getUser($_SESSION['userdata']['id']); $url = 'http://'.$_SERVER['HTTP_HOST'].'/index.php?act=tickets.showTicket&id='.$id.''; $mailMsg = "".$lang['NEW_TICKET_MAIL_1']." ".$id." ".$lang['NEW_TICKET_MAIL_2']." ".$username['lastname']." ".$username['firstname']." ".$lang['NEW_TICKET_MAIL_3']." ".$row['name']." ".$lang['NEW_TICKET_MAIL_4']." ".$url." ".$lang['NEW_TICKET_MAIL_5'].""; $mail->setText($mailMsg); if(is_numeric($values['editorId']) === false ){ $mails = $user->getMailRecipients($values['projectId']); }else{ $mails = $user->getSpecificMailRecipients($id); } $to = array(); foreach($mails as $row){ array_push($to, $row['user']); } $mail->sendMail($to); */ } $tpl->assign('values', $values); } $tpl->assign('role', $_SESSION['userdata']['role']); $tpl->assign('availableUsers', $this->getAvailableUsersForTicket()); $tpl->assign('type', $this->getType()); // var_dump($tpl->get)'getAll') $tpl->assign('info', $msgKey); $tpl->assign('projects', $projects); $tpl->assign('objTickets', $this); $tpl->assign('employees', $user->getEmployees()); $tpl->display('tickets.newTicket'); }
" style="float:left; width:75px; margin-right:10px; padding:2px; border:1px solid #ddd;"/> <strong><?php echo $row['firstname']; ?> <?php echo $row['lastname']; ?> </strong><br /> <p><?php echo nl2br($row['text']); ?> </p> <div class="clear"></div> <small> <?php printf($language->lang_echo('WRITTEN_ON_BY'), $helper->timestamp2date($row['date'], 2), $helper->timestamp2date($row['date'], 1), $row['firstname'], $row['lastname']); ?> </small> | <a href="javascript:void(0);" onclick="toggleCommentBoxes(<?php echo $row['id']; ?> )"> <?php echo $language->lang_echo('COMMENT'); ?> </a> <div style="display:none;" id="comment<?php echo $row['id']; ?>
/** * 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'); } }
public function exportExcel($myTimesheets, $dateFrom, $dateTo) { function xlsWriteLabel($Row, $Col, $Value) { $L = strlen($Value); echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); echo $Value; return; } $export_file = "export.xls"; $helper = new helper(); $language = new language(); $language->setModule('timesheets'); $lang = $language->readIni(); ini_set('zlib.output_compression', 'Off'); header('Pragma: public'); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header("Pragma: no-cache"); header("Expires: 0"); header("Content-Transfer-Encoding: binary "); header('charset="utf-8"'); header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera header("Content-type: application/x-msexcel"); header('Content-Disposition: attachment; filename="' . basename($export_file) . '"'); echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); $i = 0; $sumWorktime = 0; xlsWriteLabel($i, 0, "Zeitzettel "); xlsWriteLabel($i, 1, ""); xlsWriteLabel($i, 2, ""); xlsWriteLabel($i, 3, ""); xlsWriteLabel($i, 4, ""); xlsWriteLabel($i, 5, ""); $i++; xlsWriteLabel($i, 0, "Zeitraum "); xlsWriteLabel($i, 1, "von " . $helper->timestamp2date($dateFrom, 2) . " "); xlsWriteLabel($i, 2, "bis " . $helper->timestamp2date($dateFrom, 2) . ""); xlsWriteLabel($i, 3, ""); xlsWriteLabel($i, 4, ""); xlsWriteLabel($i, 5, ""); $i++; xlsWriteLabel($i, 0, ""); xlsWriteLabel($i, 1, ""); xlsWriteLabel($i, 2, ""); xlsWriteLabel($i, 3, ""); xlsWriteLabel($i, 4, ""); xlsWriteLabel($i, 5, ""); $i++; xlsWriteLabel($i, 0, "" . $lang['DATE'] . ""); xlsWriteLabel($i, 1, "" . $lang['HOURS'] . ""); xlsWriteLabel($i, 2, "" . $lang['TICKET'] . ""); xlsWriteLabel($i, 3, "" . $lang['PROJECT'] . ""); xlsWriteLabel($i, 4, "" . $lang['KIND'] . ""); xlsWriteLabel($i, 5, "" . $lang['DESCRIPTION'] . ""); foreach ($myTimesheets as $row) { $i++; xlsWriteLabel($i, 0, "" . $helper->timestamp2date($row['workDate'], 2) . ""); xlsWriteLabel($i, 1, "" . $row['hours'] . ""); xlsWriteLabel($i, 2, "" . utf8_decode($row['headline']) . ""); xlsWriteLabel($i, 3, "" . utf8_decode($row['name']) . ""); xlsWriteLabel($i, 4, "" . $lang[$row['kind']] . ""); xlsWriteLabel($i, 5, "" . utf8_decode($row['description']) . ""); $sumWorktime = $sumWorktime + $row['hours']; } $i++; xlsWriteLabel($i, 0, ""); xlsWriteLabel($i, 1, ""); xlsWriteLabel($i, 2, ""); xlsWriteLabel($i, 3, ""); $i++; xlsWriteLabel($i, 0, "Summen"); xlsWriteLabel($i, 1, "" . $sumWorktime . ""); xlsWriteLabel($i, 2, ""); xlsWriteLabel($i, 3, ""); xlsWriteLabel($i, 4, ""); xlsWriteLabel($i, 5, ""); echo pack("ss", 0xa, 0x0); }
&encName=<?php echo $row['encName']; ?> &ext=<?php echo $row['extension']; ?> &module=<?php echo $row['module']; ?> " target="_blank"> <?php echo $row['realName']; ?> </a><br /> <?php printf("<span class=\"grey\">" . $language->lang_echo('UPLOADED_BY_ON') . "</span>", $row['firstname'], $row['lastname'], $helper->timestamp2date($row['date'], 2)); ?> <?php echo $this->displayLink('tickets.showTicket', $language->lang_echo('DELETE'), array('id' => $ticket['id'], 'delFile' => $row['encName'])); ?> <hr/> <?php } ?> <?php if (count($this->get('files')) == 0) { ?>
<?php foreach ($this->get('files') as $rowFiles) { ?> <a href="/userdata/<?php echo $rowFiles['encName']; ?> " target="_blank"> <?php echo $rowFiles['realName']; ?> </a><br /> <?php printf("<span class=\"grey\">" . $lang['UPLOADED_BY_ON'] . "</span>", $rowFiles['firstname'], $rowFiles['lastname'], $helper->timestamp2date($rowFiles['date'], 2)); ?> <?php if ($this->get('role') === 'admin') { ?> | <a href="index.php?act=projects.showProject&id=<?php echo $project['id']; ?> &delFile=<?php echo $rowFiles['encName']; ?> #anhanege"><?php echo $lang['DELETE']; ?>
$img = '/userdata/user/' . $file['encName'] . '.' . $file['extension']; } ?> <br /> <img src="<?php echo $img; ?> " style="float:left; width:100px; margin-right:10px;"/> <br /><p><?php echo nl2br($row['text']); ?> </p><br /> <div class="clear"></div> <?php printf("<small class=\"grey\">" . $language->lang_echo('WRITTEN_ON_BY') . "</small>", $helper->timestamp2date($row['date'], 2), $helper->timestamp2date($row['date'], 1), $row['firstname'], $row['lastname']); ?> <?php if ($this->get('role') === 'admin') { ?> | <a href="index.php?act=tickets.showTicket&id=<?php echo $ticket['id']; ?> &delComment=<?php echo $row['id']; ?> #commentList"> <?php
/** * 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'); } }
/** * 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'); }
/** * run - display template and edit data * * @access public * */ public function run() { $tpl = new template(); $projects = new projects(); $user = new users(); $helper = new helper(); $language = new language(); $language->setModule('tickets'); $lang = $language->readIni(); $projects = $projects->getUserProjects("open"); $msgKey = ''; if (isset($_GET['id']) === true) { $id = (int) $_GET['id']; } $row = $this->getTicket($id); $values = array('id' => $row['id'], 'headline' => $row['headline'], 'type' => $row['type'], 'description' => $row['description'], 'priority' => $row['priority'], 'production' => $row['production'], 'staging' => $row['staging'], 'projectId' => $row['projectId'], 'userId' => $row['userId'], 'date' => $helper->timestamp2date($row['date'], 2), 'dateToFinish' => $helper->timestamp2date($row['dateToFinish'], 2), 'status' => $row['status'], 'browser' => $row['browser'], 'os' => $row['os'], 'resolution' => $row['resolution'], 'version' => $row['version'], 'url' => $row['url'], 'planHours' => $row['planHours'], 'dependingTicketId' => $row['dependingTicketId'], 'editFrom' => $helper->timestamp2date($row['editFrom'], 2), 'editTo' => $helper->timestamp2date($row['editTo'], 2), 'editorId' => $row['editorId'], 'userFirstname' => $row['userFirstname'], 'userLastname' => $row['userLastname']); //Make copy of array for comparison later) $oldValues = $values; if (!empty($row) && $values['headline'] !== null) { if (isset($_POST['save'])) { $timesheet = new timesheets(); //Set admin inputs to old values, no need to use hidden fields if ($_SESSION['userdata']['role'] === 'client') { $_POST['userId'] = $oldValues['userId']; $_POST['editFrom'] = $oldValues['editFrom']; $_POST['editTo'] = $oldValues['editTo']; $_POST['editorId'] = $oldValues['editorId']; $_POST['planHours'] = $oldValues['planHours']; $_POST['dependingTicketId'] = $oldValues['dependingTicketId']; } if (!isset($_POST['production'])) { $_POST['production'] = 0; } else { $_POST['production'] = 1; } if (!isset($_POST['staging'])) { $_POST['staging'] = 0; } else { $_POST['staging'] = 1; } if (isset($_POST['editorId']) && count($_POST['editorId'])) { $editorId = implode(',', $_POST['editorId']); } else { $editorId = ''; } $values = array('id' => $id, 'headline' => $_POST['headline'], 'type' => $_POST['type'], 'description' => $_POST['description'], 'projectId' => $_POST['project'], 'priority' => $_POST['priority'], 'editorId' => $editorId, 'staging' => $_POST['staging'], 'production' => $_POST['production'], 'date' => $helper->timestamp2date(date("Y-m-d H:i:s"), 2), 'dateToFinish' => $_POST['dateToFinish'], 'status' => $_POST['status'], 'browser' => $_POST['browser'], 'os' => $_POST['os'], 'planHours' => $_POST['planHours'], 'resolution' => $_POST['resolution'], 'version' => $_POST['version'], 'url' => $_POST['url'], 'editFrom' => $_POST['editFrom'], 'editTo' => $_POST['editTo'], 'dependingTicketId' => $_POST['dependingTicketId'], 'userFirstname' => $row['userFirstname'], 'userLastname' => $row['userLastname'], 'userId' => $row['userId']); if ($values['headline'] === '') { $tpl->setNotification('ERROR_NO_HEADLINE', 'error'); $msgKey = "ERROR_NO_HEADLINE"; } elseif ($values['description'] === '') { $tpl->setNotification('ERROR_NO_DESCRIPTION', 'error'); } else { //Prepare dates for db $values['date'] = $helper->date2timestamp($values['date']); $values['dateToFinish'] = $helper->date2timestamp($values['dateToFinish']); $values['editFrom'] = $helper->date2timestamp($values['editFrom']); $values['editTo'] = $helper->date2timestamp($values['editTo']); //Update Ticket $this->updateTicket($values, $id); //Take the old value to avoid nl character $values['description'] = $_POST['description']; $values['date'] = $helper->timestamp2date($values['date'], 2); $values['dateToFinish'] = $helper->timestamp2date($values['dateToFinish'], 2); $values['editFrom'] = $helper->timestamp2date($values['editFrom'], 2); $values['editTo'] = $helper->timestamp2date($values['editTo'], 2); $tpl->setNotification('EDIT_SUCCESS', 'success'); // $msgKey = "TICKET_EDITED"; } } //File upload if (isset($_POST['upload'])) { if (htmlspecialchars($_FILES['file']['name']) !== '') { $upload = new fileupload(); $upload->initFile($_FILES['file']); $tpl->assign('info', $upload->error); if ($upload->error == '') { // hash name on server for securty reasons $newname = md5($id . time()); $upload->renameFile($newname); if ($upload->upload() === true) { $fileValues = array('encName' => $upload->file_name, 'realName' => $upload->real_name, 'date' => date("Y-m-d H:i:s"), 'ticketId' => $id, 'userId' => $_SESSION['userdata']['id']); $this->addFile($fileValues); $tpl->setNotification('FILE_UPLOADED', 'success'); } else { $tpl->setNotification('ERROR_FILEUPLOAD_' . $upload->error . '', 'error'); } } else { $tpl->setNotification('ERROR_FILEUPLOAD_' . $upload->error . '', 'error'); } } else { $tpl->setNotification('NO_FILE', 'error'); } } // var_dump($values); die(); if (!$values['projectId']) { $projectId = $row['projectId']; } else { $projectId = $values['projectId']; } $tpl->assign('role', $_SESSION['userdata']['role']); $tpl->assign('type', $this->getType()); $tpl->assign('info', $msgKey); $tpl->assign('projects', $projects); $available = $this->getAvailableUsersForTicket($projectId); $tpl->assign('availableUsers', $available); $tpl->assign('values', $values); $tpl->assign('objTickets', $this); $tpl->assign('helper', $helper); $tpl->display('tickets.editTicket'); } else { $tpl->display('general.error'); } }