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(); $id = ''; if (isset($_GET['id']) === true) { $id = (int) $_GET['id']; } $client = $this->getClient($id); if (empty($client) === false) { $file = new files(); $project = new projects(); $msgKey = ''; if ($_SESSION['userdata']['role'] == 'admin') { $tpl->assign('admin', true); } if (isset($_POST['upload'])) { if (isset($_FILES['file'])) { $msgKey = $file->upload($_FILES, 'client', $id); } } $comment = new comments(); //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, 'client'); } $tpl->assign('userClients', $this->getClientsUsers($id)); $tpl->assign('comments', $comment->getComments('client', $id)); $tpl->assign('imgExtensions', array('jpg', 'jpeg', 'png', 'gif', 'psd', 'bmp', 'tif', 'thm', 'yuv')); $tpl->assign('info', $msgKey); $tpl->assign('client', $client); $tpl->assign('clientProjects', $project->getClientProjects($id)); $tpl->assign('files', $file->getFilesByModule('client')); //var_dump($file->getFilesByModule('client')); die(); $tpl->display('clients.showClient'); } else { $tpl->display('general.error'); } }
/** * run - display template and edit data * * @access public * */ public function run() { $login = new login(session::getSID()); //Check if user is logged in if ($login->logged_in() !== true) { exit; } $helper = new helper(); $projects = new projects(); $tickets = new tickets(); $module = $_GET['module']; //Organize ajax handlers by module and action if ($module == "tickets.showAll") { // AJAX status change if (isset($_POST['ticketId'])) { $ticketId = $_POST['ticketId']; $newStatus = $_POST['newStatus']; if ($tickets->getAccessRights($ticketId)) { if ($tickets->changeStatus($ticketId, $newStatus) === true) { echo "Status was changed"; } else { echo "Error with change"; } } else { echo "You have no rights to do that."; } } } else { if ($module == "tickets.showTicket") { $users = new users(); $id = $_GET['id']; $results = $tickets->getTimelineHistory($id); $ticket = $tickets->getTicket($id); $jsonArr = array(); $description = strip_tags($ticket['description']); $description = str_replace("\n", "", $description); $description = str_replace("\r", "", $description); $json = '{"timeline": { "headline":"Ticket History for ' . $ticket['headline'] . '", "type":"default", "text":"' . $description . '", "startDate":"' . $ticket['timelineDate'] . '", "date": [ '; //Creation Date $items[] = '{ "startDate":"' . $ticket['timelineDate'] . '", "headline":"Ticket Created", "text":"<p>Ticket created by ' . $ticket['userFirstname'] . ', ' . $ticket['userLastname'] . '</p>", "asset": { "media":"", "credit":"", "caption":"" } }'; foreach ($results as $row) { $items[] = '{ "startDate":"' . $row['date'] . '", "headline":"Ticket Update", "text":"<p>' . $row['firstname'] . ', ' . $row['lastname'] . ' changed ' . $row['changeType'] . ' to ' . $row['changeValue'] . '</p>", "asset": { "media":"' . $users->getProfilePicture($row['userId']) . '", "credit":"' . $row['firstname'] . ', ' . $row['lastname'] . '", "caption":"" } }'; } $comments = new comments(); $allcomments = $comments->getComments('ticket', $id); foreach ($allcomments as $comment) { $items[] = '{ "startDate":"' . $comment['timelineDate'] . '", "headline":"New Comment", "text":' . json_encode('<p>' . $comment['firstname'] . ', ' . $comment['lastname'] . ' said:<br /> </p>' . $comment['text']) . ', "asset": { "media":"' . $users->getProfilePicture($comment['userId']) . '", "credit":"' . $comment['firstname'] . ', ' . $comment['lastname'] . '", "caption":"" } }'; } $file = new files(); $files = $file->getFilesByModule('ticket', $id); $tempStr = ''; $tempStr3 = ''; $imgExtensions = array('jpg', 'jpeg', 'png', 'gif', 'psd', 'bmp', 'tif', 'thm', 'yuv'); foreach ($files as $fileRow) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/userdata/' . $fileRow['module'] . '/' . $fileRow['encName'] . '.' . $fileRow['extension'])) { $tempStr3 .= "<img style='max-height: 50px; max-width: 70px;' src='userdata/" . $fileRow["module"] . "/" . $fileRow['encName'] . "." . $fileRow["extension"] . "' />"; $filepath = "userdata/" . $fileRow["module"] . "/" . $fileRow['encName'] . "." . $fileRow["extension"] . ""; } else { $tempStr3 .= "<img style='max-height: 50px; max-width: 70px;' src='userdata/file.png' />"; $filepath = "userdata/file.png"; } $tempStr = '{ "startDate":"' . $fileRow['timelineDate'] . '", "headline":"New File", "text":"' . $fileRow['firstname'] . ', ' . $fileRow['lastname'] . ' uploaded:<br /><a href=\'' . $filepath . '\'>' . $fileRow['realName'] . '.' . $fileRow['extension'] . '</a>",'; $tempStr3 .= '<span class=\'filename\'>' . $fileRow['realName'] . '.' . $fileRow['extension'] . '</span> </a>",'; $tempStr .= ' "asset": { "media":"' . $filepath . '", "credit":"' . $fileRow['realName'] . '.' . $fileRow['extension'] . '", "caption":"" } }'; $items[] = $tempStr; } $json .= implode(",", $items); $json .= ' ] } }'; header('Content-type: text/json'); header('Content-type: application/json'); echo $json; } else { echo "There are no ajax actions for this module"; } } }