private function show() { /* Bail out if we don't have a valid company ID. */ if (!$this->isRequiredIDValid('companyID', $_GET)) { $this->listByView('Invalid company ID.'); return; } $companyID = $_GET['companyID']; $companies = new Companies($this->_siteID); $data = $companies->get($companyID); /* Bail out if we got an empty result set. */ if (empty($data)) { $this->listByView('The specified company ID could not be found.'); return; } /* We want to handle formatting the city and state here instead * of in the template. */ $data['cityAndState'] = StringUtility::makeCityStateString($data['city'], $data['state']); /* * Replace newlines with <br />, fix HTML "special" characters, and * strip leading empty lines and spaces. */ $data['notes'] = trim(nl2br(htmlspecialchars($data['notes'], ENT_QUOTES))); /* Chop $data['notes'] to make $data['shortNotes']. */ if (strlen($data['notes']) > self::NOTES_MAXLEN) { $data['shortNotes'] = substr($data['notes'], 0, self::NOTES_MAXLEN); $isShortNotes = true; } else { $data['shortNotes'] = $data['notes']; $isShortNotes = false; } /* Hot companies [can] have different title styles than normal companies. */ if ($data['isHot'] == 1) { $data['titleClass'] = 'jobTitleHot'; } else { $data['titleClass'] = 'jobTitleCold'; } /* Link to Google Maps for this address */ if (!empty($data['address']) && !empty($data['city']) && !empty($data['state'])) { $data['googleMaps'] = '<a href="http://maps.google.com/maps?q=' . urlencode($data['address']) . '+' . urlencode($data['city']) . '+' . urlencode($data['state']); /* Google Maps will find an address without Zip. */ if (!empty($data['zip'])) { $data['googleMaps'] .= '+' . $data['zip']; } $data['googleMaps'] .= '" target=_blank><img src="images/google_maps.gif" style="border: none;" class="absmiddle" /></a>'; } else { $data['googleMaps'] = ''; } /* Attachments */ $attachments = new Attachments($this->_siteID); $attachmentsRS = $attachments->getAll(DATA_ITEM_COMPANY, $companyID); foreach ($attachmentsRS as $rowNumber => $attachmentsData) { /* Show an attachment icon based on the document's file type. */ $attachmentIcon = strtolower(FileUtility::getAttachmentIcon($attachmentsRS[$rowNumber]['originalFilename'])); $attachmentsRS[$rowNumber]['attachmentIcon'] = $attachmentIcon; } /* Job Orders for this company */ $jobOrders = new JobOrders($this->_siteID); $jobOrdersRS = $jobOrders->getAll(JOBORDERS_STATUS_ALL, -1, $companyID, -1); if (!empty($jobOrdersRS)) { foreach ($jobOrdersRS as $rowIndex => $row) { /* Convert '00-00-00' dates to empty strings. */ $jobOrdersRS[$rowIndex]['startDate'] = DateUtility::fixZeroDate($jobOrdersRS[$rowIndex]['startDate']); /* Hot jobs [can] have different title styles than normal * jobs. */ if ($jobOrdersRS[$rowIndex]['isHot'] == 1) { $jobOrdersRS[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $jobOrdersRS[$rowIndex]['linkClass'] = 'jobLinkCold'; } $jobOrdersRS[$rowIndex]['recruiterAbbrName'] = StringUtility::makeInitialName($jobOrdersRS[$rowIndex]['recruiterFirstName'], $jobOrdersRS[$rowIndex]['recruiterLastName'], false, LAST_NAME_MAXLEN); $jobOrdersRS[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($jobOrdersRS[$rowIndex]['ownerFirstName'], $jobOrdersRS[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN); } } /* Contacts for this company */ $contacts = new Contacts($this->_siteID); $contactsRS = $contacts->getAll(-1, $companyID); $contactsRSWC = null; if (!empty($contactsRS)) { foreach ($contactsRS as $rowIndex => $row) { /* Hot contacts [can] have different title styles than normal contacts. */ if ($contactsRS[$rowIndex]['isHot'] == 1) { $contactsRS[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $contactsRS[$rowIndex]['linkClass'] = 'jobLinkCold'; } if (!empty($contactsRS[$rowIndex]['ownerFirstName'])) { $contactsRS[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($contactsRS[$rowIndex]['ownerFirstName'], $contactsRS[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN); } else { $contactsRS[$rowIndex]['ownerAbbrName'] = 'None'; } if ($contactsRS[$rowIndex]['leftCompany'] == 0) { $contactsRSWC[] = $contactsRS[$rowIndex]; } else { $contactsRS[$rowIndex]['linkClass'] = 'jobLinkDead'; } } } /* Add an MRU entry. */ $_SESSION['CATS']->getMRU()->addEntry(DATA_ITEM_COMPANY, $companyID, $data['name']); /* Get extra fields. */ $extraFieldRS = $companies->extraFields->getValuesForShow($companyID); /* Get departments. */ $departmentsRS = $companies->getDepartments($companyID); /* Is the user an admin - can user see history? */ if ($this->_accessLevel < ACCESS_LEVEL_DEMO) { $privledgedUser = false; } else { $privledgedUser = true; } $this->_template->assign('active', $this); $this->_template->assign('data', $data); $this->_template->assign('attachmentsRS', $attachmentsRS); $this->_template->assign('departmentsRS', $departmentsRS); $this->_template->assign('extraFieldRS', $extraFieldRS); $this->_template->assign('isShortNotes', $isShortNotes); $this->_template->assign('jobOrdersRS', $jobOrdersRS); $this->_template->assign('contactsRS', $contactsRS); $this->_template->assign('contactsRSWC', $contactsRSWC); $this->_template->assign('privledgedUser', $privledgedUser); $this->_template->assign('companyID', $companyID); if (!eval(Hooks::get('CLIENTS_SHOW'))) { return; } $this->_template->display('./modules/companies/Show.tpl'); }
private function edit() { /* Bail out if we don't have a valid contact ID. */ if (!$this->isRequiredIDValid('contactID', $_GET)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid contact ID.'); } $contactID = $_GET['contactID']; $contacts = new Contacts($this->_siteID); $data = $contacts->getForEditing($contactID); /* Bail out if we got an empty result set. */ if (empty($data)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'The specified contact ID could not be found.'); } $companies = new Companies($this->_siteID); $companiesRS = $companies->getSelectList(); $users = new Users($this->_siteID); $usersRS = $users->getSelectList(); /* Add an MRU entry. */ $_SESSION['CATS']->getMRU()->addEntry(DATA_ITEM_CONTACT, $contactID, $data['firstName'] . ' ' . $data['lastName']); /* Get extra fields. */ $extraFieldRS = $contacts->extraFields->getValuesForEdit($contactID); /* Get departments. */ $departmentsRS = $companies->getDepartments($data['companyID']); $departmentsString = ListEditor::getStringFromList($departmentsRS, 'name'); $emailTemplates = new EmailTemplates($this->_siteID); $statusChangeTemplateRS = $emailTemplates->getByTag('EMAIL_TEMPLATE_OWNERSHIPASSIGNCONTACT'); if (!isset($statusChangeTemplateRS['disabled']) || $statusChangeTemplateRS['disabled'] == 1) { $emailTemplateDisabled = true; } else { $emailTemplateDisabled = false; } $reportsToRS = $contacts->getAll(-1, $data['companyID']); if ($this->_accessLevel == ACCESS_LEVEL_DEMO) { $canEmail = false; } else { $canEmail = true; } $companies = new Companies($this->_siteID); $defaultCompanyID = $companies->getDefaultCompany(); if ($defaultCompanyID !== false) { $defaultCompanyRS = $companies->get($defaultCompanyID); } else { $defaultCompanyRS = array(); } if (!eval(Hooks::get('CONTACTS_EDIT'))) { return; } $this->_template->assign('defaultCompanyID', $defaultCompanyID); $this->_template->assign('defaultCompanyRS', $defaultCompanyRS); $this->_template->assign('canEmail', $canEmail); $this->_template->assign('emailTemplateDisabled', $emailTemplateDisabled); $this->_template->assign('active', $this); $this->_template->assign('data', $data); $this->_template->assign('companiesRS', $companiesRS); $this->_template->assign('extraFieldRS', $extraFieldRS); $this->_template->assign('departmentsRS', $departmentsRS); $this->_template->assign('departmentsString', $departmentsString); $this->_template->assign('usersRS', $usersRS); $this->_template->assign('reportsToRS', $reportsToRS); $this->_template->assign('contactID', $contactID); $this->_template->assign('sessionCookie', $_SESSION['CATS']->getCookie()); $this->_template->display('./modules/contacts/Edit.tpl'); }
function share() { $id = array_var($_GET, 'object_id'); $manager = array_var($_GET, 'manager'); $obj = get_object_by_manager_and_id($id, $manager); if (!$obj instanceof DataObject) { flash_error(lang('object dnx')); ajx_current("empty"); return; } // if $contacts = Contacts::getAll(); $allEmails = array(); $emailAndComp = array(); foreach ($contacts as $contact) { if (trim($contact->getEmail()) != "") { $emailStr = str_replace(",", " ", $contact->getFirstname() . ' ' . $contact->getLastname() . ' <' . $contact->getEmail() . '>'); $allEmails[] = $emailStr; if ($contact->getCompany()) { $emailAndComp[$emailStr] = $contact->getCompany()->getId(); } } } $companies = Companies::getAll(); $allCompanies = array(); foreach ($companies as $comp) { $allCompanies[$comp->getId()] = $comp->getName(); } $actuallySharing = array(); $users = SharedObjects::getUsersSharing($id, $manager); foreach ($users as $u) { $user = Users::findById($u->getUserId()); if ($user) { $actuallySharing[] = array('name' => $user->getDisplayName(), 'email' => $user->getEmail(), 'company' => $user->getCompany()->getName()); } } tpl_assign('allEmails', $allEmails); tpl_assign('allCompanies', $allCompanies); tpl_assign('emailAndComp', $emailAndComp); tpl_assign('actuallySharing', $actuallySharing); tpl_assign('object', $obj); }
header("Location: /staff/?id=notFound"); exit; } if (isset($_GET['go']) && $_GET['go'] == "y") { $contactsDelete = new Contacts(); $contactsDelete->setContactsid($_GET['id']); $contactsDelete->deleteFromDB(); header("Location: /contacts/?ItemDeleted=y"); exit; } include "../tmpl/header.php"; $contacts = new Contacts(); // Load DB data into object $contacts->setContactsid($_GET['id']); $contacts->loadContacts(); $all = $contacts->getAll(); if (isset($all)) { ?> <div class="panel panel-info"> <div class="panel-heading"> <strong>Viewing <?php echo $contacts->getContactsid(); ?> </strong> </div> <div class="panel-body"> <?php foreach ($all as $key => $value) { if (isset($value) && $value != '') { ?>
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/contacts.php"; session_start(); if (empty($_SESSION['list_of_contacts'])) { $_SESSION['list_of_contacts'] = array(); } $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get("/", function () use($app) { return $app['twig']->render('home.html.twig', array('contact' => Contacts::getAll())); }); $app->post("/create_contact", function () use($app) { $contact = new Contacts($_POST['list_of_contacts']); $contact->save(); return $app['twig']->render('create_contact.html.twig', array('newcontact' => $contact)); }); $app->post("/delete_contacts", function () use($app) { Task::deleteAll(); return $app['twig']->render('delete_contacts.html.twig'); }); return $app;