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');
 }
 function upload()
 {
     $im = @getimagesize($_FILES["pic"]["tmp_name"]);
     if ($im[2]) {
         parent::upload();
     } else {
         $_SESSION["warning"] = "Файл <b>" . $_FILES["pic"]["name"] . "</b> не является графическим!";
         header("Location: ?chid={$this->chid}&dir={$this->dir}&w=1");
     }
 }
 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');
 }
 /**
  * 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');
     }
 }
Beispiel #5
0
 /**
  * setPicture - set the profile picture for an individual
  * 
  * @access public
  * @param string 
  */
 public function setPicture($_FILE, $id)
 {
     $sql = "SELECT * FROM `zp_user` WHERE id=:id";
     $stmn = $this->db->{'database'}->prepare($sql);
     $stmn->bindValue(':id', $id, PDO::PARAM_INT);
     $stmn->execute();
     $values = $stmn->fetch();
     $stmn->closeCursor();
     $files = new files();
     if (isset($values['profileId']) && $values['profileId'] > 0) {
         $file = $files->getFile($values['profileId']);
         $img = 'userdata/' . $file['encName'] . $file['extension'];
         $files->deleteFile($values['profileId']);
     }
     $lastId = $files->upload($_FILE, 'user', $id);
     var_dump($lastId);
     $sql = 'UPDATE `zp_user` SET profileId = :fileId WHERE id = :userId';
     $stmn = $this->db->{'database'}->prepare($sql);
     $stmn->bindValue(':fileId', $lastId, PDO::PARAM_INT);
     $stmn->bindValue(':userId', $id, PDO::PARAM_INT);
     $stmn->execute();
     $stmn->closeCursor();
 }
Beispiel #6
0
        } else {
            if ($Question->add_question($_POST['event'], $input, $_POST['option1'], $_POST['option2'], $_POST['option3'], $_POST['option4'], $_POST['option5'], $_POST['correct_answer'], NULL, 1, NULL, $usID)) {
                echo 'Question Added';
            } else {
                echo 'There was an error';
            }
        }
    }
}
if ($_POST['FRQuestion']) {
    $Question = new Questions();
    $input = htmlspecialchars($_POST['inputquest']);
    $usID = $user->data['user_id'];
    if (strlen($_FILES['userfile']['name']) > 1) {
        $file = new files();
        $imageLocation = $file->upload($_FILES['userfile']['name'], $_FILES['userfile']['size'], $_FILES['userfile']['tmp_name'], $_FILES['userfile']['type']);
        // add_question($eventId,    $question,   $a,  $b,   $c, $d, $e,  $correct,$image,  $type, $keywords,   $userID)
        if ($Question->add_question($_POST['event'], $input, NULL, NULL, NULL, NULL, NULL, NULL, $imageLocation, 4, $_POST['keywords'], $usID)) {
            echo 'Question Added';
        } else {
            echo 'There was an error';
        }
    } else {
        if (strlen($_POST['URL']) > 1) {
            $file = new files();
            $imageLocation = $file->pull_image($_POST['URL']);
            // add_question($eventId,$question,        $a,  $b,   $c, $d, $e,  $correct,$image,  $type, $keywords,   $userID)
            if ($Question->add_question($_POST['event'], $input, NULL, NULL, NULL, NULL, NULL, NULL, $imageLocation, 4, $_POST['keywords'], $usID)) {
                echo 'Question Added';
            } else {
                echo 'There was an 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();
     $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');
     }
 }
Beispiel #9
0
<?php

$custom_css = array('articles.scss');
$page_title = 'Admin - Articles';
define("PAGE_PRIV", "admin_pub");
require_once 'init.php';
if (isset($_FILES["file"])) {
    require 'class.files.php';
    $upload = files::upload($_FILES["file"]);
}
require_once 'header.php';
if ($upload) {
    $app->utils->message('Image uploaded: ' . $upload, 'good');
} else {
    $app->utils->message('Error uploading image');
}
?>

<form enctype="multipart/form-data" method="post">
	<input type="file" name="file" size="40">
	<input type="submit" value="Send" class='left button'>
</form>

<?php 
require_once 'footer.php';