public function run() { $tpl = new template(); $id = (int) $_GET['id']; if ($id > 0) { $lead = $this->getLead($id); // Comments $comments = new comments(); if (isset($_POST['comment']) === true) { $values = array('text' => $_POST['text'], 'date' => date("Y-m-d H:i:s"), 'userId' => $_SESSION['userdata']['id'], 'moduleId' => $id, 'commentParent' => $_POST['father']); $comments->addComment($values, 'lead'); } // files $file = new files(); if (isset($_POST['upload'])) { if (isset($_FILES['file'])) { $file->upload($_FILES, 'lead', $id); $tpl->setNotification('FILE_UPLOADED', 'success'); } else { $tpl->setNotification('NO_FILE', 'error'); } } $files = new files(); $tpl->assign('files', $files->getFilesByModule('lead', $id)); $tpl->assign('comments', $comments->getComments('lead', $id)); $tpl->assign('contactInfo', $this->getLeadContact($id)); $tpl->assign('lead', $lead); } else { $tpl->display('general.error'); } $tpl->display('leads.showLead'); }
/** * 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) { $id = (int) $_GET['id']; $row = $this->getClient($id); $msgKey = ''; $values = array('name' => $row['name'], 'street' => $row['street'], 'zip' => $row['zip'], 'city' => $row['city'], 'state' => $row['state'], 'country' => $row['country'], 'phone' => $row['phone'], 'internet' => $row['internet'], 'email' => $row['email']); if (isset($_POST['save']) === true) { $values = array('name' => $_POST['name'], 'street' => $_POST['street'], 'zip' => $_POST['zip'], 'city' => $_POST['city'], 'state' => $_POST['state'], 'country' => $_POST['country'], 'phone' => $_POST['phone'], 'internet' => $_POST['internet'], 'email' => $_POST['email']); if ($values['name'] !== '') { $this->editClient($values, $id); $tpl->setNotification('EDIT_CLIENT_SUCCESS', 'success'); } else { $tpl->setNotification('NO_NAME', 'error'); } } $tpl->assign('values', $values); $tpl->display('clients.editClient'); } else { $tpl->display('general.error'); } } else { $tpl->display('general.error'); } }
/** * run - display template and edit data * * @access public */ public function run() { $tpl = new template(); $user = new users(); //Only admins if ($user->isAdmin($_SESSION['userdata']['id'])) { $msgKey = ''; if (isset($_POST['save']) === true) { $values = array('name' => $_POST['name'], 'street' => $_POST['street'], 'zip' => $_POST['zip'], 'city' => $_POST['city'], 'state' => $_POST['state'], 'country' => $_POST['country'], 'phone' => $_POST['phone'], 'internet' => $_POST['internet'], 'email' => $_POST['email']); if ($values['name'] !== '') { if ($this->isClient($values) !== true) { $this->addClient($values); $tpl->setNotification('ADD_CLIENT_SUCCESS', 'success'); } else { $tpl->setNotification('CLIENT_EXISTS', 'error'); } } else { $tpl->setNotification('NO_NAME', 'error'); } $tpl->assign('values', $values); } $tpl->display('clients.newClient'); } else { $tpl->display('general.error'); } }
/** * run - display template and edit data * * @access public */ public function run() { $tpl = new template(); $helper = new helper(); $values = array('description' => '', 'dateFrom' => '', 'dateTo' => '', 'allDay' => ''); if (isset($_POST['save']) === true) { if (isset($_POST['allDay']) === true) { $allDay = 'true'; } else { $allDay = 'false'; } if (isset($_POST['dateFrom']) === true && isset($_POST['timeFrom']) === true) { $dateFrom = $helper->date2timestamp($_POST['dateFrom'], $_POST['timeFrom']); } if (isset($_POST['dateTo']) === true && isset($_POST['timeTo']) === true) { $dateTo = $helper->date2timestamp($_POST['dateTo'], $_POST['timeTo']); } $values = array('description' => $_POST['description'], 'dateFrom' => $dateFrom, 'dateTo' => $dateTo, 'allDay' => $allDay); if ($values['description'] !== '') { if ($helper->validateTime($_POST['timeFrom']) === true) { $this->addEvent($values); $msgKey = $tpl->setNotification('SAVE_SUCCESS', 'success'); } else { $tpl->setNotification('WRONG_TIME_FORMAT', 'error'); } } else { $tpl->setNotification('NO_DESCRIPTION', 'error'); } $tpl->assign('values', $values); } $tpl->assign('helper', $helper); $tpl->display('calendar.addEvent'); }
/** * run - display template and edit data * * @access public * */ public function run() { $tpl = new template(); $infoKey = ''; //Build values array $values = array('name' => '', 'parent' => '', 'module' => '', 'action' => '', 'icon' => ''); if (isset($_POST['save'])) { if (isset($_POST['module'])) { $module = str_replace('index.php?act=', '', $_POST['module']); $module = explode('.', $module); $action = $module[1]; $module = $module[0]; $values = array('name' => $_POST['name'], 'parent' => $_POST['parent'], 'module' => $module, 'action' => $action, 'icon' => $_POST['icon']); $this->addMenu($values); $tpl->setNotification('New menu item successfully created', 'success'); // $infoKey = '<p>Erfolgreich hinzugefügt</p>'; } else { $tpl->setNotification('MISSING_FIELDS', 'error'); } } $getModuleLinks = $this->getAllModulesAsLinks(); $tpl->assign('wholeMenu', $this->getWholeMenu()); $tpl->assign('moduleLinks', $getModuleLinks); $tpl->assign('info', $infoKey); $tpl->assign('values', $values); $tpl->assign('applications', $this->applications); $tpl->display('setting.addMenu'); }
public function run() { $tpl = new template(); $language = new language(); $language->setModule('leads'); $language->readIni(); if (isset($_POST['save'])) { if (isset($_POST['name']) && isset($_POST['money']) && isset($_POST['referralSource'])) { $refValue = ''; if ($_POST['referralValueOther'] != '') { $refValue = $_POST['referralValueOther']; } else { if ($_POST['referralSource'] == 5 && $_POST['referralValueClient'] > 0) { $refValue = $_POST['referralValueClient']; } } $values = array('name' => $_POST['name'], 'refSource' => $_POST['referralSource'], 'refValue' => $refValue, 'potentialMoney' => $_POST['money'], 'creatorId' => $_SESSION['userdata']['id']); $contact = array('name' => $_POST['clientName'], 'street' => $_POST['street'], 'zip' => $_POST['zip'], 'city' => $_POST['city'], 'state' => $_POST['state'], 'country' => $_POST['country'], 'phone' => $_POST['phone'], 'email' => $_POST['email'], 'internet' => $_POST['internet']); if ($this->isLead($values['name']) !== true) { $leadId = $this->addLead($values); $this->addLeadContact($contact, $leadId); $tpl->setNotification('EDIT_SUCCESS', 'success'); } else { $tpl->setNotification('LEAD_EXISTS', 'error'); } } else { $tpl->setNotification('MISSING_FIELDS', 'error'); } } $client = new clients(); $tpl->assign('referralSources', $this->getReferralSources()); $tpl->assign('clients', $client->getAll()); $tpl->display('leads.addLead'); }
public function run() { $tpl = new template(); $id = (int) $_GET['id']; $users = new users(); $clients = new clients(); if ($id && $id > 0) { $lead = $this->getLead($id); $contact = $this->getLeadContact($id); $values = array('user' => $contact['email'], 'password' => '', 'firstname' => '', 'lastname' => '', 'phone' => $contact['phone'], 'role' => 3, 'clientId' => $lead['clientId']); if (isset($_POST['save'])) { if (isset($_POST['user']) && isset($_POST['firstname']) && isset($_POST['lastname'])) { $hasher = new PasswordHash(8, TRUE); $values = array('user' => $_POST['user'], 'password' => $hasher->HashPassword($_POST['password']), 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'phone' => $_POST['phone'], 'role' => $_POST['role'], 'clientId' => $_POST['clientId']); if ($users->usernameExist($values['user']) !== true) { $users->addUser($values); $tpl->setNotification('USER_CREATED', 'success'); } else { $tpl->setNotification('USERNAME_EXISTS', 'error'); } } else { $tpl->setNotification('MISSING_FIELDS', 'error'); } } $tpl->assign('values', $values); $tpl->assign('clients', $clients->getAll()); $tpl->assign('roles', $users->getRoles()); $tpl->display('leads.convertToUser'); } else { $tpl->display('general.error'); } }
public function run() { $tpl = new template(); if (isset($_POST['save'])) { if (isset($_POST['title']) && isset($_POST['submoduleAlias'])) { $this->addWidget($_POST['submoduleAlias'], $_POST['title']); $tpl->setNotification('SAVE_SUCCESS', 'success'); } else { $tpl->setNotification('MISSING_FIELDS', 'error'); } } $setting = new setting(); $tpl->assign('submodules', $setting->getAllSubmodules()); $tpl->display('dashboard.addWidget'); }
public function run() { $tpl = new template(); $id = (int) $_GET['id']; if ($id > 0) { $lead = $this->getLead($id); $values = array('name' => $lead['name'], 'potentialMoney' => $lead['potentialMoney'], 'actualMoney' => $lead['actualMoney'], 'refSource' => $lead['refSource'], 'refValue' => $lead['refValue'], 'status' => $lead['status'], 'proposal' => $lead['proposal']); $clients = new clients(); $dbClient = $clients->getClient($lead['clientId']); $client = array('name' => $dbClient['name'], 'street' => $dbClient['street'], 'zip' => $dbClient['zip'], 'city' => $dbClient['city'], 'state' => $dbClient['state'], 'country' => $dbClient['country'], 'phone' => $dbClient['phone'], 'email' => $dbClient['email'], 'internet' => $dbClient['internet']); if (isset($_POST['save'])) { if (isset($_FILES['file'])) { if (htmlspecialchars($_FILES['file']['name']) !== '') { $file = new files(); $file->upload($_FILES, 'lead', $id); } } if (isset($_POST['name']) && isset($_POST['referralSource']) && isset($_POST['money']) && isset($_POST['status'])) { $refValue = ''; if ($_POST['referralSource'] && $_POST['referralValueOther'] != '') { $refValue = $_POST['referralValueOther']; } else { if ($_POST['referralSource'] == 5 && $_POST['referralValueClient'] > 0) { $refValue = $_POST['referralValueClient']; } } $values = array('name' => $_POST['name'], 'potentialMoney' => $_POST['money'], 'actualMoney' => $_POST['actualMoney'], 'refSource' => $_POST['referralSource'], 'refValue' => $refValue, 'status' => $_POST['status']); $client = array('name' => $_POST['clientName'], 'street' => $_POST['street'], 'zip' => $_POST['zip'], 'city' => $_POST['city'], 'state' => $_POST['state'], 'country' => $_POST['country'], 'phone' => $_POST['phone'], 'email' => $_POST['email'], 'internet' => $_POST['internet']); $this->editLead($values, $id); $clients->editClient($client, $lead['clientId']); $tpl->setNotification('EDIT_SUCCESS', 'success'); } else { $tpl->setNotification('MISSING_FIELDS', 'error'); } } $tpl->assign('client', $client); $tpl->assign('lead', $values); } else { $tpl->display('general.error'); } $client = new clients(); $tpl->assign('status', $this->getStatus()); $tpl->assign('referralSources', $this->getReferralSources()); $tpl->assign('clients', $client->getAll()); $tpl->display('leads.editLead'); }
public function run() { $tpl = new template(); // Messages $msg = ''; $id = NULL; // Compose if (isset($_POST['send'])) { if (isset($_POST['username']) && isset($_POST['subject']) && isset($_POST['content'])) { $values = array('from_id' => $_SESSION['userdata']['id'], 'to_id' => $_POST['username'], 'subject' => $_POST['subject'], 'content' => $_POST['content']); $this->sendMessage($values); $tpl->setNotification('MESSAGE_SENT', 'success'); } else { $tpl->setNotification('MISSING_FIELDS', 'error'); } } if (isset($_POST['reply'])) { if (isset($_POST['message'])) { $values = array('content' => $_POST['message'], 'to_id' => $_POST['to_id'], 'from_id' => $_SESSION['userdata']['id']); $this->reply($values, $_POST['parent_id']); } } $myMessages = $this->getMessages($_SESSION['userdata']['id']); $users = new users(); $user = $users->getUser($_SESSION['userdata']['id']); if (!isset($_GET['id'])) { $messages = $this->getMessages($_SESSION['userdata']['id'], 1); foreach ($messages as $message) { $id = $message['id']; } } else { $id = $_GET['id']; $this->markAsRead($id); } $tpl->assign('info', $msg); $tpl->assign('displayId', $id); $tpl->assign('userEmail', $user['username']); $tpl->assign('messages', $myMessages); $tpl->assign('friends', $this->getPeople()); $tpl->display('messages.showAll'); }
/** * run - display template and edit data * * @access public * */ public function run() { $tpl = new template(); if (isset($_GET['id']) === true) { $id = (int) $_GET['id']; $row = $this->getMenuById($id); $infoKey = ''; //Build values array $values = array('name' => $row['name'], 'link' => $row['link'], 'parent' => $row['parent'], 'inTopNav' => $row['inTopNav'], 'orderNum' => $row['orderNum'], 'application' => $row['application'], 'action' => $row['action'], 'module' => $row['module'], 'icon' => $row['icon']); if (isset($_POST['save'])) { if (isset($_POST['name'])) { $action = ''; $module = ''; if (isset($_POST['module'])) { $module = str_replace('index.php?act=', '', $_POST['module']); $module = explode('.', $module); $action = $module[1]; $module = $module[0]; } $values = array('name' => $_POST['name'], 'module' => $module, 'action' => $action, 'icon' => $_POST['icon'], 'parent' => $_POST['parent']); $this->editMenu($values, $id); $tpl->setNotification('Menu item edited!', 'success'); } else { $tpl->setNotification('MISSING_FIELDS', 'error'); } } $getModuleLinks = $this->getAllModulesAsLinks(); // $publicContent = new publicContent(); //Assign vars // $tpl->assign('articles', $publicContent->getAllArticles()); //Assign vars $tpl->assign('wholeMenu', $this->getWholeMenu()); $tpl->assign('moduleLinks', $getModuleLinks); $tpl->assign('info', $infoKey); $tpl->assign('values', $values); $tpl->assign('applications', $this->applications); $tpl->display('setting.editMenu'); } else { $tpl->display('general.error'); } }
public function run() { $tpl = new template(); $currentModule = ''; if (isset($_GET['id'])) { $currentModule = $_GET['id']; } if (isset($_POST['upload'])) { if (isset($_FILES['file'])) { $this->upload($_FILES, 'private', 0); $tpl->setNotification('FILE_UPLOADED', 'success'); } else { $tpl->setNotification('NO_FILES', 'error'); } } $tpl->assign('folders', $this->getFolders($currentModule)); $tpl->assign('currentModule', $currentModule); $tpl->assign('modules', $this->getModules($_SESSION['userdata']['id'])); $tpl->assign('imgExtensions', array('jpg', 'jpeg', 'png', 'gif', 'psd', 'bmp', 'tif', 'thm', 'yuv')); $tpl->assign('files', $this->getFilesByModule($currentModule, NULL, $_SESSION['userdata']['id'])); $tpl->display('files.showAll'); }
/** * run - display template and edit data * * @access public * */ public function run() { $tpl = new template(); $hasher = new PasswordHash(8, TRUE); //only Admins if ($_SESSION['userdata']['role'] == 'admin') { $values = array(); if (isset($_POST['save'])) { $values = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'user' => $_POST['user'], 'phone' => $_POST['phone'], 'role' => $_POST['role'], 'password' => $hasher->HashPassword($_POST['password']), 'clientId' => $_POST['client']); //Validation if ($values['user'] !== '') { $helper = new helper(); if ($helper->validateEmail($values['user']) == 1) { if ($hasher->CheckPassword($_POST['password'], $values['password']) && $_POST['password'] != '') { if ($this->usernameExist($values['user']) === false) { $this->addUser($values); $tpl->setNotification('USER_ADDED', 'success'); } else { $tpl->setNotification('USERNAME_EXISTS', 'error'); } } else { $tpl->setNotification('PASSWORDS_DONT_MATCH', 'error'); } } else { $tpl->setNotification('NO_VALID_EMAIL', 'error'); } } else { $tpl->setNotification('NO_USERNAME', 'error'); } $tpl->assign('values', $values); } $clients = new clients(); $tpl->assign('clients', $clients->getAll()); $tpl->assign('roles', $this->getRoles()); $tpl->display('users.newUser'); } else { $tpl->display('general.error'); } }
public function run() { $tpl = new template(); $id = (int) $_GET['id']; if ($id > 0) { if (isset($_POST['save'])) { $values = array('street' => $_POST['street'], 'zip' => $_POST['zip'], 'city' => $_POST['city'], 'state' => $_POST['state'], 'country' => $_POST['country'], 'phone' => $_POST['phone'], 'internet' => $_POST['internet']); $this->addLeadContact($values, $id); $tpl->setNotification('EDIT_SUCCESS', 'success'); } } else { $tpl->display('general.error'); } $tpl->display('leads.addLeadContact'); }
/** * run - display template and edit data * * @access public * @return */ public function run() { $tpl = new template(); if (isset($_GET['id']) === true) { $id = (int) $_GET['id']; $msgKey = ''; //Delete User if (isset($_POST['del']) === true) { $this->deleteMenu($id); $tpl->setNotification('Menu item deleted!', 'success'); } //Assign variables $tpl->assign('msg', $msgKey); $tpl->display('setting.delMenu'); } else { $tpl->display('general.error'); } }
public function run() { $tpl = new template(); $id = (int) $_GET['id']; $language = new language(); $language->setModule('leads'); $language->readIni(); if ($id > 0) { if (isset($_POST['delete'])) { $this->deleteLead($id); $tpl->setNotification($language->lang_echo('LEAD_DELETED'), 'success'); } $tpl->assign('lead', $this->getLead($id)); } else { $tpl->display('general.error'); } $tpl->display('leads.deleteLead'); }
public function run() { $tpl = new template(); $id = (int) $_GET['id']; if ($id > 0) { $account = $this->getProjectAccount($id); $values = array('name' => $_POST['name'], 'username' => $_POST['username'], 'password' => $_POST['password'], 'host' => $_POST['host'], 'kind' => $_POST['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); } else { $tpl->setNotification('MISSING_FIELDS', 'error'); } } else { $tpl->display('general.error'); } $tpl->assign('account', $values); $tpl->display('projects.editAccount'); }
/** * 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'); } }
/** * 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'); } }
/** * 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'); }
/** * 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) { $id = (int) $_GET['id']; $row = $this->getProject($id); $msgKey = ''; $values = array('name' => $row['name'], 'details' => $row['details'], 'clientId' => $row['clientId'], 'state' => $row['state'], 'hourBudget' => $row['hourBudget'], 'assignedUsers' => $this->getProjectUserRelation($id), 'dollarBudget' => $row['dollarBudget']); //Edit project if (isset($_POST['save']) === true) { if (isset($_POST['editorId']) && count($_POST['editorId'])) { $assignedUsers = $_POST['editorId']; } else { $assignedUsers = array(); } $values = array('name' => $_POST['name'], 'details' => $_POST['details'], 'clientId' => $_POST['clientId'], 'state' => $_POST['projectState'], 'hourBudget' => $_POST['hourBudget'], 'assignedUsers' => $assignedUsers, 'dollarBudget' => $_POST['dollarBudget']); if ($values['name'] !== '') { if ($this->hasTickets($id) && $values['state'] == 1) { $tpl->setNotification('PROJECT_HAS_TICKETS', 'error'); } else { $this->editProject($values, $id); //Take the old value to avoid nl character $values['details'] = $_POST['details']; $tpl->setNotification('PROJECT_EDITED', 'success'); } } else { $tpl->setNotification('NO_PROJECTTNAME', 'error'); } } //Add Account if (isset($_POST['accountSubmit']) === true) { $accountValues = array('name' => $_POST['accountName'], 'kind' => $_POST['kind'], 'username' => $_POST['username'], 'password' => $_POST['password'], 'host' => $_POST['host'], 'projectId' => $id); if ($accountValues['name'] !== '') { $this->addProjectAccount($accountValues); $tpl->setNotification('ACCOUNT_ADDED', 'sucess'); } else { $tpl->setNotification('NO_ACCOUNT_NAME', 'error'); } $tpl->assign('accountValues', $accountValues); } //Upload file if (isset($_POST['upload']) === true) { if ($_FILES['file']['name'] !== '') { $upload = new fileupload(); $upload->initFile($_FILES['file']); if ($upload->error == '') { //Name on Server is encoded $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', 'error'); } } else { $tpl->setNotification('ERROR_FILEUPLOAD', 'error'); } } else { $tpl->setNotification('NO_FILE', 'error'); } } $helper = new helper(); $clients = new clients(); $user = new users(); $tpl->assign('availableUsers', $user->getAll()); //Assign vars $tpl->assign('info', $msgKey); $tpl->assign('clients', $clients->getAll()); $tpl->assign('values', $values); $tpl->assign('files', $this->getFiles($id)); $tpl->assign('helper', $helper); $tpl->assign('accounts', $this->getProjectAccounts($id)); $tpl->display('projects.editProject'); } else { $tpl->display('general.error'); } } else { $tpl->display('general.error'); } }
/** * @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'); }
/** * run - display template and edit data * * @access public * */ public function run() { $tpl = new template(); $hasher = new PasswordHash(8, TRUE); $userId = $_SESSION['userdata']['id']; $row = $this->getUser($userId); // $projects = $this->getUserProjectRelation($userId); $infoKey = ''; //Build values array $values = array('firstname' => $row['firstname'], 'lastname' => $row['lastname'], 'user' => $row['username'], 'phone' => $row['phone'], 'role' => $row['role']); //Save form if (isset($_POST['save'])) { $values = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'user' => $_POST['user'], 'phone' => $_POST['phone'], 'password' => $hasher->HashPassword($_POST['newPassword'])); $changedEmail = 0; if ($row['username'] != $values['user']) { $changedEmail = 1; } //Validation if ($values['user'] !== '') { $helper = new helper(); if ($helper->validateEmail($values['user']) == 1) { if ($_POST['newPassword'] == $_POST['confirmPassword']) { if ($_POST['newPassword'] == '') { $values['password'] = ''; } else { $this->editOwn($values, $userId); } if ($changedEmail == 1) { if ($this->usernameExist($values['user'], $userId) === false) { $this->editOwn($values, $userId); $tpl->setNotification('EDIT_SUCCESS', 'success'); } else { $tpl->setNotification('USERNAME_EXISTS', 'error'); } } else { $this->editOwn($values, $userId); $tpl->setNotification('EDIT_SUCCESS', 'success'); } } else { $tpl->setNotification('PASSWORDS_DONT_MATCH', 'ERROR'); } } else { $tpl->setNotification('NO_VALID_EMAIL', 'error'); } } else { $tpl->setNotification('NO_USERNAME', 'error'); } } $file = new files(); if (isset($_POST['savePic'])) { if (isset($_FILES)) { $this->setPicture($_FILES, $_SESSION['userdata']['id']); } } //Assign vars $users = new users(); // $tpl->assign('profilePic', $file->getFilesByModule('user',$_SESSION['userdata']['id'])); $tpl->assign('profilePic', $users->getProfilePicture($_SESSION['userdata']['id'])); $tpl->assign('info', $infoKey); $tpl->assign('values', $values); //$tpl->assign('roles', $this->roles); $tpl->assign('user', $row); $tpl->display('users.editOwn'); }
/** * 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'); } }
/** * 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 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'); } }