public function displayForm($mysql, $cid = 0, $ownerid = 0) { $name = ""; $email = ""; $phone = ""; if($cid != 0) { $con = new Contact(); switch($con->select($cid, $ownerid, $mysql)) { case Contact::DATABASE_ERROR : { echo "<p>A Database error has occured.</p>"; return; } case Contact::INVALID_DATA : { echo "<p>Invalid operation requested.</p>"; return; } case Contact::SELECT_SUCCESS : { $name = $con->getName(); $email = $con->getEmail(); $phone = $con->getPhone(); break; } default : break; } } echo <<<FORM <div id="contact"> <form action="" method="POST"> <input type='hidden' name='cid' value='$cid'> <table> <tbody> <tr> <td>Name</td> <td><input type="text" name="cname" value="$name"/></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" value="$email"/></td> </tr> <tr> <td>Phone</td> <td><input type="text" name="phone" value="$phone"/></td> </tr> <tr> <td><input type="reset" value="Reset"/></td> <td><input type="submit" name="action" value="Save"/></td> </tr> </tbody> </table> </form> </div> FORM; }
public function testContact() { $contact = new Contact('firstname', 'lastname', 'organisation', 'address1', 'address2', 'address3', 'suburb', 'state', new Country('AU'), 'postcode', new Phone('+61.111111111'), new Email('*****@*****.**'), new Phone('+61.222222222')); $this->assertEquals('firstname', $contact->getFirstname()); $this->assertEquals('lastname', $contact->getLastname()); $this->assertEquals('organisation', $contact->getOrganisation()); $this->assertEquals('address1', $contact->getAddress1()); $this->assertEquals('address2', $contact->getAddress2()); $this->assertEquals('address3', $contact->getAddress3()); $this->assertEquals('suburb', $contact->getSuburb()); $this->assertEquals('state', $contact->getState()); $this->assertInstanceOf('SynergyWholesale\\Types\\Country', $contact->getCountry()); $this->assertEquals('AU', $contact->getCountry()->getCountryCode()); $this->assertEquals('postcode', $contact->getPostcode()); $this->assertInstanceOf('SynergyWholesale\\Types\\Phone', $contact->getPhone()); $this->assertEquals('+61.111111111', $contact->getPhone()->getPhone()); $this->assertInstanceOf('SynergyWholesale\\Types\\Email', $contact->getEmail()); $this->assertEquals('*****@*****.**', $contact->getEmail()->getEmail()); $this->assertInstanceOf('SynergyWholesale\\Types\\Phone', $contact->getFax()); $this->assertEquals('+61.222222222', $contact->getFax()->getPhone()); }
public function view() { if (empty($this->id)) { \Layout::add('<h1>Sorry</h1><p>This property is not in our system. Please return to the <a href="./">property listing page</a> to try again.</p>'); return; } $tpl = $this->getBaseTpl(); $refund = '<span style="font-size : 90%">(Refundable)</span>'; \PHPWS_Core::initModClass('properties', 'Contact.php'); $max_width = PANEL_WIDTH; $max_height = PANEL_HEIGHT; \Layout::addStyle('properties', 'view.css'); $tpl['NAME'] = $this->viewLink($this->name); $photos = $this->getPhotos(); if ($photos) { javascriptMod('properties', 'galleryview', array('panel_width' => $max_width, 'panel_height' => $max_height)); foreach ($photos as $p) { if (is_file($p['path'])) { $dim = getimagesize($p['path']); $width =& $dim[0]; $height =& $dim[1]; $diff = \PHPWS_File::getDiff($width, $max_width, $height, $max_height); $new_width = round($width * $diff); $new_height = round($height * $diff); if ($new_width > $max_width || $new_height > $max_height) { $diff = \PHPWS_File::getDiff($new_width, $max_width, $new_height, $max_height); $new_width = round($width * $diff); $new_height = round($height * $diff); } } else { $p['path'] = PHPWS_SOURCE_HTTP . 'mod/properties/img/no_photo.gif'; $p['title'] = 'Photo not found'; $new_width = '150px'; $new_height = '113px'; } $all[] = sprintf('<li><img src="%s" title="%s" /> <div class="panel-content lightbox"> <a class="lightbox" href="%s"><img src="%s" width="%s" height="%s" /></a> </div></li>', Photo::thumbnailPath($p['path']), $p['title'], $p['path'], $p['path'], $new_width, $new_height); } $tpl['PHOTOS'] = implode("\n", $all); } else { $tpl['NO_PHOTO'] = '<img src="' . PHPWS_SOURCE_HTTP . 'mod/properties/img/no_photo.gif" alt="No photo" title="No photos available" />'; } $contact = new Contact($this->contact_id); if (!empty($contact->company_address)) { $tpl['COMPANY_ADDRESS'] = $contact->getCompanyAddress(); $tpl['GOOGLE_COMPANY'] = sprintf('<a target="_blank" href="http://maps.google.com/maps?q=%s"> <img class="google-map" src="%smod/properties/img/google-pin-red.gif" title="Google maps" target="_blank" /></a>', Property::googleMapUrl($contact->company_address), PHPWS_SOURCE_HTTP); } $tpl['COMPANY_NAME'] = $contact->getCompanyUrl(); $tpl['EMAIL'] = $contact->getEmailAddress(true); $tpl['PHONE'] = $contact->getPhone(); $tpl['TIMES_AVAILABLE'] = $contact->getTimesAvailable(); $tpl['ADDRESS'] = $this->getAddress(); $tpl['GOOGLE_MAP'] = sprintf('<a target="_blank" href="http://maps.google.com/maps?q=%s"> <img src="%smod/properties/img/google-pin-red.gif" title="Google maps" target="_blank" /></a>', Property::googleMapUrl($this->address), PHPWS_SOURCE_HTTP); $tpl['LEASE_TYPE'] = $this->getLeaseType(); if ($this->efficiency) { $tpl['BEDROOMS'] = 'One room efficiency'; } else { $tpl['BEDROOMS'] = $this->bedroom_no; } $tpl['BATHROOMS'] = $this->getBathroomNo(); if ($this->window_number) { $tpl['WINDOWS'] = 'Yes'; } else { $tpl['WINDOWS'] = 'No'; } if (!empty($this->admin_fee_amt)) { $tpl['ADMIN_FEE'] = '$' . $this->getAdminFeeAmt(); $tpl['ADMIN_FEE_REFUND'] = $this->admin_fee_refund ? $refund : null; } if (!empty($this->parking_fee)) { $tpl['PARKING_FEE'] = '$' . $this->getParkingFee(); } if (!empty($this->security_amt)) { $tpl['SECURITY_AMT'] = '$' . $this->getSecurityAmt(); $tpl['SECURITY_REFUND'] = $this->security_refund ? $refund : null; } if (!empty($this->other_fees)) { $tpl['OTHER_FEES'] = $this->getOtherFees(); } if (!empty($this->clean_fee_amt)) { $tpl['CLEAN_FEE_AMT'] = '$' . $this->getCleanFeeAmt(); $tpl['CLEAN_FEE_REFUND'] = $this->clean_fee_refund ? $refund : null; } $tpl['PARKING_PER_UNIT'] = $this->getParkingPerUnit(); if ($this->pets_allowed) { $tpl['PETS_ALLOWED'] = 'Yes'; $tpl['PET_TYPES'] = $this->getPetType(); if ($this->pet_deposit) { $tpl['PET_DEPOSIT'] = '$' . $this->getPetDeposit() . ' <span style="font-size : 90%">(refundable)</span>'; } else { $tpl['PET_DEPOSIT'] = 'None'; } if ($this->pet_fee) { $tpl['PET_FEE'] = '$' . $this->getPetFee() . ' <span style="font-size : 90%">(nonrefundable)</span>'; } else { $tpl['PET_FEE'] = 'None'; } } else { $tpl['PETS_ALLOWED'] = 'No'; } $utility_allowance = false; $tpl['STUDENT_TYPE'] = $this->getStudentType(); if ($this->util_water) { $utility_allowance = true; $tpl['UTIL_WATER'] = $this->getUtilWater(); } if ($this->util_trash) { $utility_allowance = true; $tpl['UTIL_TRASH'] = $this->getUtilTrash(); } if ($this->util_power) { $utility_allowance = true; $tpl['UTIL_POWER'] = $this->getUtilPower(); } if ($this->util_fuel) { $utility_allowance = true; $tpl['UTIL_FUEL'] = $this->getUtilFuel(); } if ($this->util_cable) { $utility_allowance = true; $tpl['UTIL_CABLE'] = $this->getUtilCable(); } if ($this->util_internet) { $utility_allowance = true; $tpl['UTIL_INTERNET'] = $this->getUtilInternet(); } if ($this->util_phone) { $utility_allowance = true; $tpl['UTIL_PHONE'] = $this->getUtilPhone(); } $photo = new Photo(); $photo->setPropertyId($this->id); if (isset($_GET['photo'])) { $data['pid'] = $this->id; } $data['view'] = 1; if (\Current_User::allow('properties')) { javascriptMod('properties', 'photo_upload', $data); $tpl['ADD_PHOTO'] = $photo->uploadNew(false); $tpl['EDIT'] = \PHPWS_Text::secureLink('<i class="fa fa-edit"></i> Edit', 'properties', array('aop' => 'edit_property', 'pid' => $this->id), null, null, 'btn btn-default'); if (!$this->active) { $tpl['ACTIVE'] = '<div id="not-active">This property is currently NOT ACTIVE</div>'; } } elseif (isset($_SESSION['Contact_User']->id) && $_SESSION['Contact_User']->id == $this->contact_id) { if (!$this->active) { $tpl['ACTIVE'] = '<div id="not-active">This property is currently NOT ACTIVE</div>'; } $data['is_contact'] = 1; javascriptMod('properties', 'photo_upload', $data); $tpl['ADD_PHOTO'] = $photo->uploadNew(false); $tpl['EDIT'] = \PHPWS_Text::moduleLink('Edit property', 'properties', array('cop' => 'edit_property', 'pid' => $this->id, 'k' => $_SESSION['Contact_User']->getKey())); } elseif (!$this->active) { \Layout::add('This property is currently not available'); return; } $heat_type = $this->getHeatType(); if ($heat_type) { $tpl['HEAT_TYPE'] = implode(', ', $this->getHeatType()); } $content = \PHPWS_Template::process($tpl, 'properties', 'view.tpl'); \Layout::add($content); }
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/JobOpening.php"; require_once __DIR__ . "/../src/Contact.php"; $app = new Silex\Application(); // Home Page $app->get("/", function () { return "\n <!DOCTYPE html>\n <html>\n <head>\n <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n <title>Post a Job</title>\n </head>\n\n <body>\n <div class='container'>\n <div class='row'>\n <div class='col-sm-6'>\n <h1>Post a Job</h1>\n <form action='/results'>\n <div class='form-group'>\n <label for='title'>Enter the job title:</label>\n <input id='title' name='title' class='form-control' type='text'>\n </div>\n <div class='form-group'>\n <label for='description'>Enter the job description:</label>\n <input id='description' name='description' class='form-control' type='text'>\n </div>\n <div class='form-group'>\n <label for='name'>Enter your name:</label>\n <input id='name' name='name' class='form-control' type='text'>\n </div>\n <div class='form-group'>\n <label for='phone'>Enter your phone number:</label>\n <input id='phone' name='phone' class='form-control' type='number'>\n </div>\n <div class='form-group'>\n <label for='email'>Enter your email:</label>\n <input id='email' name='email' class='form-control' type='text'>\n </div>\n <button type='submit' class='btn-success'>Submit</button>\n </form>\n </div>\n </div>\n </div>\n </body>\n </html>"; }); // Results Page $app->get("/results", function () { $contact = new Contact($_GET['name'], $_GET['phone'], $_GET['email']); $newJob = new JobOpening($_GET['title'], $_GET['description'], $contact); $output = "<h3>Job: " . $newJob->getTitle() . "</h3>\n <h4>Description: " . $newJob->getDescription() . "</h4>\n <p>Name: " . $contact->getName() . "</p>\n <p>Phone: " . $contact->getPhone() . "</p>\n <p>email: " . $contact->getEmail() . "</p><hr>"; return "\n <!DOCTYPE html>\n <html>\n <head>\n <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n <title>Posted Job</title>\n </head>\n\n <body>\n <div class='container'>\n <div class='row'>\n <div class='col-sm-8'>" . $output . "</div>\n </div>\n </div>\n </body>\n </html>"; }); return $app;
<li><label for="position">Position</label><br /> <input type="text" name="position" id="position" class="required" value="<?php echo $item->getPosition(); ?> " /></li> <li><label for="email" >Email</label><br /> <input type="text" name="email" id="email" value="<?php echo $item->getEmail(); ?> " /></li> <li><label for="phone" >Phone</label><br /> <input type="text" name="phone" id="phone" value="<?php echo $item->getPhone(); ?> " /></li> </ul> <?php // create token $salt = 'SomeSalt'; $token = sha1(mt_rand(1, 1000000) . $salt); $_SESSION['token'] = $token; ?> <input type="hidden" name="id" id="id" value="<?php echo $item->getId(); ?> " /> <input type="hidden" name="task" id="task" value="contact.maint" />
public function updateContact(Contact $contact) { if ($contact != null && ($contact->getId() == null || $contact->getId() == -1)) { return false; } try { if ($contact->getAddress() != null && $contact->getAddress()->getId() != null && $contact->getAddress()->getId() != -1) { $this->addressService->updateAddress($contact->getAddress()); } if (!parent::getBdd()->inTransaction()) { parent::getBdd()->beginTransaction(); } $query = "UPDATE CONTACT SET firstName = :fName, name = :name, mail = :mail,\n phone = :phone, phone2 = :phone2, phone3 = :phone3, company = :company, type = :type, exchangeId = :exchangeId\n WHERE id = :id"; $request = parent::getBdd()->prepare($query); $request->bindParam(':id', $contact->getId()); if ($contact->getFirstName() != null) { $request->bindParam(':fName', $contact->getFirstName()); } else { $request->bindValue(':fName', null); } if ($contact->getName() != null) { $request->bindParam(':name', $contact->getName()); } else { $request->bindValue(':name', null); } if ($contact->getMail() != null) { $request->bindParam(':mail', $contact->getMail()); } else { $request->bindValue(':mail', null); } if ($contact->getPhone() != null) { $request->bindParam(':phone', $contact->getPhone()); } else { $request->bindValue(':phone', null); } if ($contact->getPhone2() != null) { $request->bindParam(':phone2', $contact->getPhone2()); } else { $request->bindValue(':phone2', null); } if ($contact->getPhone3() != null) { $request->bindParam(':phone3', $contact->getPhone3()); } else { $request->bindValue(':phone3', null); } if ($contact->getCompany() != null) { $request->bindParam(':company', $contact->getCompany()); } else { $request->bindValue(':company', null); } if ($contact->getType() != null && $contact->getType()->getId() != null && $contact->getType()->getId() != -1) { $request->bindParam(':type', $contact->getType()->getId()); } elseif ($contact->getType() != null && ($contact->getType()->getId() == null || $contact->getType()->getId() == -1) && $contact->getType()->getLabel() != null) { $typeId = $this->typeService->getTypeIdByLabel($contact->getType()->getLabel()); if ($typeId != -1) { $request->bindParam(':type', $typeId); } else { $request->bindValue(':type', null); } } else { $request->bindValue(':type', null); } if ($contact->getExchangeId() != null) { $request->bindParam(':exchangeId', $contact->getExchangeId()); } else { $request->bindValue(':exchangeId', null); } $request->execute(); parent::getBdd()->commit(); $request->closeCursor(); return true; } catch (Exception $e) { error_log($e->getMessage()); } return false; }
<?php return ""; }); $app->get("/posting", function () { $job_opening = new JobOpening($_GET["title"], $_GET["des"]); $contact = new Contact($_GET["phone"], $_GET["email"], $_GET["address"]); ?> <p><?php echo $job_opening->getTitle(); ?> </p> <p><?php echo $job_opening->getDes(); ?> </p> <p><?php echo $contact->getPhone(); ?> </p> <p><?php echo $contact->getEmail(); ?> </p> <p><?php echo $contact->getAddress(); ?> </p> <?php return ""; }); return $app;
<li><label for="position">Position</label><br /> <input type="text" name="position" id="position" class="required" value="<?php echo htmlspecialchars($item->getPosition()); ?> " /></li> <li><label for="email" >Email</label><br /> <input type="text" name="email" id="email" value="<?php echo htmlspecialchars($item->getEmail()); ?> " /></li> <li><label for="phone" >Phone</label><br /> <input type="text" name="phone" id="phone" value="<?php echo htmlspecialchars($item->getPhone()); ?> " /></li> </ul> <?php // create token $salt = 'SomeSalt'; $token = sha1(mt_rand(1, 1000000) . $salt); $_SESSION['token'] = $token; ?> <input type="hidden" name="id" id="id" value="<?php echo $item->getId(); ?> " /> <input type="hidden" name="task" id="task" value="contact.maint" />
public function addContact(Contact $c) { try { $request = new EWSType_CreateItemType(); $contact = new EWSType_ContactItemType(); if ($c->getFirstName() != null) { $contact->GivenName = $c->getFirstName(); } if ($c->getType() != null) { $contact->Surname = $c->getName() . ' -- ' . $c->getType()->getLabel(); } else { $contact->Surname = $c->getName(); } if ($c->getMail() != null) { $email = new EWSType_EmailAddressDictionaryEntryType(); $email->Key = new EWSType_EmailAddressKeyType(); $email->Key->_ = EWSType_EmailAddressKeyType::EMAIL_ADDRESS_1; $email->_ = $c->getMail(); $contact->EmailAddresses = new EWSType_EmailAddressDictionaryType(); $contact->EmailAddresses->Entry[] = $email; } if ($c->getCompany() != null) { $contact->CompanyName = $c->getCompany(); } $addr = $c->getAddress(); if ($addr != null) { $address = new EWSType_PhysicalAddressDictionaryEntryType(); $address->Key = new EWSType_PhysicalAddressKeyType(); $address->Key->_ = EWSType_PhysicalAddressKeyType::BUSINESS; if ($addr->getLine1() != null) { if ($addr->getLine2() != null) { $address->Street = $addr->getLine1() . ' ' . $addr->getLine2(); } else { $address->Street = $addr->getLine1(); } } if ($addr->getCity() != null) { $address->City = $addr->getCity(); } if ($addr->getZipCode() != null) { $address->PostalCode = $addr->getZipCode(); } $contact->PhysicalAddresses = new EWSType_PhysicalAddressDictionaryType(); $contact->PhysicalAddresses->Entry[] = $address; } if ($c->getPhone() != null) { $phone = new EWSType_PhoneNumberDictionaryEntryType(); $phone->Key = new EWSType_PhoneNumberKeyType(); $phone->Key->_ = EWSType_PhoneNumberKeyType::BUSINESS_PHONE; $phone->_ = $c->getPhone(); $contact->PhoneNumbers->Entry[] = $phone; } if ($c->getPhone2() != null) { $phone = new EWSType_PhoneNumberDictionaryEntryType(); $phone->Key = new EWSType_PhoneNumberKeyType(); $phone->Key->_ = EWSType_PhoneNumberKeyType::BUSINESS_PHONE_2; $phone->_ = $c->getPhone2(); if ($contact->PhoneNumbers == null) { $contact->PhoneNumbers = new EWSType_PhoneNumberDictionaryType(); } $contact->PhoneNumbers->Entry[] = $phone; } if ($c->getPhone3() != null) { $phone = new EWSType_PhoneNumberDictionaryEntryType(); $phone->Key = new EWSType_PhoneNumberKeyType(); $phone->Key->_ = EWSType_PhoneNumberKeyType::OTHER_PHONE; $phone->_ = $c->getPhone3(); if ($contact->PhoneNumbers == null) { $contact->PhoneNumbers = new EWSType_PhoneNumberDictionaryType(); } $contact->PhoneNumbers->Entry[] = $phone; } $contact->FileAsMapping = new EWSType_FileAsMappingType(); //? $contact->FileAsMapping->_ = EWSType_FileAsMappingType::FIRST_SPACE_LAST; $request->Items->Contact[] = $contact; $result = parent::getEws()->CreateItem($request); if ($result->ResponseMessages->CreateItemResponseMessage->Items->Contact->ItemId->Id != null) { $c->setExchangeId($result->ResponseMessages->CreateItemResponseMessage->Items->Contact->ItemId->Id); } return true; } catch (Exception $e) { error_log($e->getMessage()); } return false; }