Ejemplo n.º 1
0
 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');
 }
Ejemplo n.º 2
0
 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');
     }
 }
Ejemplo n.º 3
0
 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');
 }
Ejemplo n.º 4
0
 /**
  * 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');
     }
 }
Ejemplo n.º 5
0
 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     $msgKey = '';
     $values = array('name' => '', 'details' => '', 'clientId' => '', 'hourBudget' => '', 'assignedUsers' => array(), 'dollarBudget' => '');
     if (isset($_POST['save']) === true) {
         if (!isset($_POST['hourBudget']) || $_POST['hourBudget'] == '' || $_POST['hourBudget'] == NULL) {
             $hourBudget = '0';
         } else {
             $hourBudget = $_POST['hourBudget'];
         }
         if (isset($_POST['editorId']) && count($_POST['editorId'])) {
             $assignedUsers = $_POST['editorId'];
         } else {
             $assignedUsers = array();
         }
         $values = array('name' => $_POST['name'], 'details' => $_POST['details'], 'clientId' => $_POST['clientId'], 'hourBudget' => $hourBudget, 'assignedUsers' => $assignedUsers, 'dollarBudget' => $_POST['dollarBudget']);
         if ($values['name'] === '') {
             $msgKey = 'NO_PROJECTNAME';
         } elseif ($values['clientId'] === '') {
             $msgKey = 'ERROR_NO_CLIENT';
         } else {
             $this->addProject($values);
             //Take the old value to avoid nl character
             $values['details'] = $_POST['details'];
             $msgKey = 'PROJECT_ADDED';
         }
         $tpl->assign('values', $values);
     }
     $tpl->assign('values', $values);
     $user = new users();
     $tpl->assign('availableUsers', $user->getAll());
     $clients = new clients();
     $tpl->assign('info', $msgKey);
     $tpl->assign('clients', $clients->getAll());
     $tpl->display('projects.newProject');
 }
Ejemplo n.º 6
0
 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     //Only admins
     if ($_SESSION['userdata']['role'] == 'admin') {
         if (isset($_GET['id']) === true) {
             $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');
     }
 }
Ejemplo n.º 7
0
 /**
  * run - display template and edit data
  *
  * @access public
  *
  */
 public function run()
 {
     $tpl = new template();
     //Only admins
     if ($_SESSION['userdata']['role'] == 'admin') {
         if (isset($_GET['id']) === true) {
             $project = new projects();
             $id = (int) $_GET['id'];
             $row = $this->getUser($id);
             $edit = false;
             $infoKey = '';
             //Build values array
             $values = array('firstname' => $row['firstname'], 'lastname' => $row['lastname'], 'user' => $row['username'], 'phone' => $row['phone'], 'status' => $row['status'], 'role' => $row['role'], 'hours' => $row['hours'], 'wage' => $row['wage'], 'clientId' => $row['clientId']);
             if (isset($_POST['save'])) {
                 $values = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'user' => $_POST['user'], 'phone' => $_POST['phone'], 'status' => $_POST['status'], 'role' => $_POST['role'], 'hours' => $_POST['hours'], 'wage' => $_POST['wage'], 'clientId' => $_POST['client']);
                 $changedEmail = 0;
                 if ($row['username'] != $values['user']) {
                     $changedEmail = 1;
                 }
                 if ($values['user'] !== '') {
                     $helper = new helper();
                     if ($helper->validateEmail($values['user']) === 1) {
                         if ($changedEmail == 1) {
                             if ($this->usernameExist($row['username'], $id) === false) {
                                 $edit = true;
                             } else {
                                 $tpl->setNotification('USERNAME_EXISTS', 'error');
                             }
                         } else {
                             $edit = true;
                         }
                     } else {
                         $tpl->setNotification('NO_VALID_EMAIL_' . $helper->validateEmail($values['user']), 'error');
                     }
                 } else {
                     $tpl->setNotification('NO_USERNAME', 'error');
                 }
             }
             //Was everything okay?
             if ($edit !== false) {
                 $this->editUser($values, $id);
                 if (isset($_POST['projects'])) {
                     if ($_POST['projects'][0] !== '0') {
                         $project->editUserProjectRelations($id, $_POST['projects']);
                     } else {
                         $project->deleteAllProjectRelations($id);
                     }
                 }
                 $tpl->setNotification('EDIT_SUCCESS', 'success');
             }
             // Get relations to projects
             $projects = $project->getUserProjectRelation($id);
             $projectrelation = array();
             foreach ($projects as $projectId) {
                 $projectrelation[] = $projectId['projectId'];
             }
             //Assign vars
             $clients = new clients();
             $tpl->assign('clients', $clients->getAll());
             $tpl->assign('allProjects', $project->getAll());
             $tpl->assign('values', $values);
             $tpl->assign('relations', $projectrelation);
             $tpl->assign('roles', $this->getRoles());
             $tpl->assign('status', $this->status);
             $tpl->display('users.editUser');
         } else {
             $tpl->display('general.error');
         }
     } else {
         $tpl->display('general.error');
     }
 }