Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('lib/AbstractEntity.class.php');
- class Client extends AbstractEntity {
- /** @var int accountNumber */
- var $accountNumber = null;
- /** @var string company */
- var $company = null;
- /** @var int industryId */
- var $industryId = null;
- /** @var string firstName */
- var $firstName = null;
- /** @var string lastName */
- var $lastName = null;
- /** @var string address1 */
- var $address1 = null;
- /** @var string address2 */
- var $address2 = null;
- /** @var string city */
- var $city = null;
- /** @var string state */
- var $state = null;
- /** @var string zip */
- var $zip = null;
- /** @var string country */
- var $country = null;
- /** @var string email */
- var $email = null;
- /** @var string phone */
- var $phone = null;
- /** @var string password */
- var $username = null;
- var $password = null;
- /** @var int salesRep */
- var $salesRep = null;
- /** @var string status */
- var $status = null;
- /** @var string string */
- var $string = null;
- var $reseller = null;
- var $resellerDiscount = null;
- var $howHeard = null;
- var $cards = array();
- var $promo = null; //promotion object
- var $promoCode = null;
- var $referralID = null;
- /** @var boolean tenPercentResller */
- var $tenPercentResller = null;
- /** @var string tenPercentReferralID */
- var $tenPercentReferralID = null;
- /* these fields are used during domain ordering, but are never saved in the DB at this point 7.8.08 NM */
- var $shipFirstName = null;
- var $shipLastName = null;
- var $shipCompany = null;
- var $shipCompanyTitle = null;
- var $shipAddress1 = null;
- var $shipAddress2 = null;
- var $shipCity = null;
- var $shipState = null;
- var $shipCountry = null;
- var $shipZip = null;
- var $fax = null;
- var $table = 'clients';
- var $fields = array('id', 'accountNumber', 'company', 'industryId', 'firstName', 'lastName',
- 'address1', 'address2', 'city', 'state', 'zip', 'country', 'email', 'phone',
- 'username', 'password', 'salesRep', 'status', 'howHeard',
- 'string', 'reseller', 'resellerDiscount', 'promoCode', 'paypalPreferred', 'tenPercentReseller', 'tenPercentReferralID', 'referralID');
- function Client($id=null){
- if(null != $id){
- $this->setString($id);
- //$this->abstractEntity($id);
- $this->setId($id);
- require_once(dirname(__FILE__) . '/ClientDAO.class.php');
- $dao = new ClientDAO();
- $dao->_populate($this);
- }
- }
- /**
- * Updates the status of this client
- *
- * @author nikita m
- * @param string $status the status to switch to
- */
- function updateStatus($status){
- require_once('lib/ClientDAO.class.php');
- $dao = new ClientDAO();
- $dao->updateStatus($status, $this);
- }
- function getUpdateValueArray($var=null){
- $retArr = array();
- $fields = $this->getFields($var);
- foreach($fields as $x => $field){
- if($field != 'password'){
- $xvar = 'get'.ucfirst($field);
- $retArr[] = ($this->$xvar()) ? $this->$xvar() : '';
- }
- }
- return $retArr;
- }
- function getUpdatePrepareString($var=null){
- $new = array();
- $fields = $this->getFields($var);
- if(is_array($fields)){
- foreach($fields as $field){
- if($field != 'password'){
- $new[] = $field . ' = |';
- }
- }
- return join(', ', $new);
- }
- }
- /**
- * Updates the record information in the database. Overrides parent method.
- *
- * @author nikita m
- */
- function update(){
- require_once(dirname(__FILE__) . '/ClientDAO.class.php');
- $dao = new ClientDAO();
- return $dao->update($this);
- }
- /**
- * Populates this object using the email
- *
- * @author nikita m
- */
- function loadFromEmail(){
- require_once(dirname(__FILE__) . '/ClientDAO.class.php');
- $dao = new ClientDAO();
- $this->setId($dao->getIdFromEmail($this));
- $dao->_populate($this);
- }
- /**
- * Checks to see this object's credentials against entries in the database to see if they are valid
- *
- * @author nikita m
- * @return bool
- */
- function canLogin(){
- require_once(dirname(__FILE__) . '/ClientDAO.class.php');
- $dao = new ClientDAO();
- return $dao->canLogin($this);
- }
- /**
- * Checks the object's string value against the db to see if they match. If they do,
- * the client is logged in, otherwise he is not
- *
- * @author nikita m
- * @return bool
- */
- function isLoggedIn(){
- $myString = $this->getString();
- if(!$myString || $myString == ""){
- return false;
- }
- require_once(dirname(__FILE__) . '/ClientDAO.class.php');
- $dao = new ClientDAO();
- return $dao->isLoggedIn($this);
- }
- /**
- * Checks to see if the client with a given email already exists in the DB
- *
- * @author nikita m
- * @return bool
- */
- function exists(){
- require_once(dirname(__FILE__) . '/ClientDAO.class.php');
- $dao = new ClientDAO();
- return $dao->exists($this);
- }
- /**
- * Convert internal military state codes into their appropriate abbreviations
- *
- * @author matt delong
- * @param string $state the internal state code
- * @return string
- */
- function convertMilitaryState($state){
- /*
- Armed Forces Africa A1 = AE
- Armed Forces Americas A2 = AA
- Armed Forces Canada A3 = AE
- Armed Forces Europe A4 = AE
- Armed Forces Middle East A5 = AE
- Armed Forces Pacific A6 = AP
- */
- switch($state){
- case 'A1':
- return 'AE';
- break;
- case 'A2':
- return 'AA';
- break;
- case 'A3':
- return 'AE';
- break;
- case 'A4':
- return 'AE';
- break;
- case 'A5':
- return 'AE';
- break;
- case 'A6':
- return 'AP';
- break;
- default:
- return $state;
- }
- }
- /** MUTATORS & ACCESSORS */
- function setShipFirstName($value) {
- $this->shipFirstName = $value;
- }
- function getShipFirstName() {
- return $this->shipFirstName;
- }
- function setShipLastName($value) {
- $this->shipLastName = $value;
- }
- function getShipLastName() {
- return $this->shipLastName;
- }
- function setShipCompany($value) {
- $this->shipCompany = $value;
- }
- function getShipCompany() {
- return $this->shipCompany;
- }
- function setShipCompanyTitle($value) {
- $this->shipCompanyTitle = $value;
- }
- function getShipCompanyTitle() {
- return $this->shipCompanyTitle;
- }
- function setShipAddress1($value) {
- $this->shipAddress1 = $value;
- }
- function getShipAddress1() {
- return $this->shipAddress1;
- }
- function setShipAddress2($value) {
- $this->shipAddress2 = $value;
- }
- function getShipAddress2() {
- return $this->shipAddress2;
- }
- function setShipCity($value) {
- $this->shipCity = $value;
- }
- function getShipCity() {
- return $this->shipCity;
- }
- function setShipState($value) {
- $this->shipState = $value;
- }
- function getShipState() {
- return $this->shipState;
- }
- function setShipCountry($value) {
- $this->shipCountry = $value;
- }
- function getShipCountry() {
- return $this->shipCountry;
- }
- function setShipZip($value) {
- $this->shipZip = $value;
- }
- function getShipZip() {
- return $this->shipZip;
- }
- function setFax($value) {
- $this->fax = $value;
- }
- function getFax() {
- return $this->fax;
- }
- function getHowHeard(){
- return $this->howHeard;
- }
- function setHowHeard($value){
- $this->howHeard = $value;
- }
- /**
- * Sets the accountNumber
- *
- * @param int $accountNumber
- */
- function setAccountNumber ($accountNumber ){$this->accountNumber = $accountNumber ;}
- /**
- * Gets the accountNumber
- *
- * @return int
- */
- function getAccountNumber (){return $this->accountNumber ;}
- /**
- * Sets the company
- *
- * @param string $company
- */
- function setCompany ($company ){$this->company = $company ;}
- /**
- * Gets the company
- *
- * @return string
- */
- function getCompany (){return $this->company ;}
- /**
- * Sets the industryId
- *
- * @param int $industryId
- */
- function setIndustryId ($industryId ){$this->industryId = $industryId ;}
- /**
- * Gets the industryId
- *
- * @return int
- */
- function getIndustryId (){return $this->industryId ;}
- /**
- * Sets the firstName
- *
- * @param string $firstName
- */
- function setFirstName ($firstName ){$this->firstName = $firstName ;}
- /**
- * Gets the firstName
- *
- * @return string
- */
- function getFirstName (){return $this->firstName ;}
- /**
- * Sets the lastName
- *
- * @param string $lastName
- */
- function setLastName ($lastName ){$this->lastName = $lastName ;}
- /**
- * Gets the lastName
- *
- * @return string
- */
- function getLastName (){return $this->lastName ;}
- /**
- * Sets the address1
- *
- * @param string $address1
- */
- function setAddress1 ($address1 ){$this->address1 = $address1 ;}
- /**
- * Gets the address1
- *
- * @return string
- */
- function getAddress1 (){return $this->address1 ;}
- /**
- * Sets the address2
- *
- * @param string $address2
- */
- function setAddress2 ($address2 ){$this->address2 = $address2 ;}
- /**
- * Gets the address2
- *
- * @return string
- */
- function getAddress2 (){return $this->address2 ;}
- /**
- * Sets the city
- *
- * @param string $city
- */
- function setCity ($city ){$this->city = $city ;}
- /**
- * Gets the city
- *
- * @return string
- */
- function getCity (){return $this->city ;}
- /**
- * Sets the state
- *
- * @param string $state
- */
- function setState ($state ){$this->state = $state ;}
- /**
- * Gets the state
- *
- * @return string
- */
- function getState ($convert=false){
- $state = $this->state;
- if($convert){
- $state = $this->convertMilitaryState($state);
- }
- return $state;
- }
- /**
- * Sets the zip
- *
- * @param string $zip
- */
- function setZip ($zip ){$this->zip = $zip ;}
- /**
- * Gets the zip
- *
- * @return string
- */
- function getZip (){return $this->zip ;}
- /**
- * Sets the country
- *
- * @param string $country
- */
- function setCountry ($country ){$this->country = $country ;}
- /**
- * Gets the country
- *
- * @return string
- */
- function getCountry (){return $this->country ;}
- /**
- * Sets the email
- *
- * @param string $email
- */
- function setEmail ($email ){$this->email = $email ;}
- /**
- * Gets the email
- *
- * @return string
- */
- function getEmail (){return $this->email ;}
- /**
- * Sets the phone
- *
- * @param string $phone
- */
- function setPhone ($phone ){$this->phone = $phone ;}
- /**
- * Gets the phone
- *
- * @return string
- */
- function getPhone (){return $this->phone ;}
- /**
- * Sets the password
- *
- * @param string $password
- */
- function setPassword ($password ){
- require_once(dirname(__FILE__) . '/framework/Util.class.php');
- $this->password = Util::rot13($password);
- }
- /**
- * Gets the password
- *
- * @return string
- */
- function getPassword (){return $this->password ;}
- function getUsername(){
- return $this->username;
- }
- function setUsername($value){
- $this->username = $value;
- }
- /**
- * Sets the salesRep
- *
- * @param int $salesRep
- */
- function setSalesRep ($salesRep ){$this->salesRep = $salesRep ;}
- /**
- * Gets the salesRep
- *
- * @return int
- */
- function getSalesRep (){return $this->salesRep ;}
- /**
- * Sets the status
- *
- * @param string $status
- */
- function setStatus ($status ){$this->status = $status ;}
- /**
- * Gets the status
- *
- * @return string
- */
- function getStatus (){return $this->status ;}
- /**
- * Sets the string
- *
- * @param string $string
- */
- function setString($string){$this->string = $string;}
- /**
- * Gets the string
- *
- * @return string
- */
- function getString(){return $this->string;}
- function getStoreId(){
- return $this->storeId;
- }
- function setStoreId($value){
- $this->storeId = $value;
- }
- function getCards(){
- return $this->cards;
- }
- function addCard($card){
- $this->cards[] = $card;
- }
- function setCards($value){
- $this->cards = $value;
- }
- function _populateRunCards(){
- require_once(dirname(__FILE__) . '/ClientDAO.class.php');
- $dao = new ClientDAO();
- $dao->_populateRunCards($this);
- }
- function _populateCards(){
- require_once(dirname(__FILE__) . '/ClientDAO.class.php');
- $dao = new ClientDAO();
- $dao->_populateCards($this);
- }
- function getReseller(){
- return $this->reseller;
- }
- function setReseller($value){
- $this->reseller = $value;
- }
- function getResellerDiscount(){
- return $this->resellerDiscount;
- }
- function setResellerDiscount($value){
- $this->resellerDiscount = $value;
- }
- function getPromo(){
- global $request;
- if($promoCode = $request->getCookie('offerCode')){
- require_once('lib/Promotion.class.php');
- $promo = new Promotion($promoCode);
- if(!$promo->hasExpired()){
- $this->promo = $promo;
- return $promo;
- }
- }
- return false;
- }
- function getPromoCode(){
- global $request;
- if($promoCode = $request->getCookie('offerCode')){
- $promo = $this->getPromo();
- if($promo && !$promo->hasExpired()){
- return $promoCode;
- }
- }
- return false;
- }
- function setPromoCode($value){
- $this->promoCode = $value;
- }
- function getMyIpCountry(){
- require_once('lib/IpAddress.class.php');
- require_once('lib/IpLocation.class.php');
- $ip = IpAddress::getMyIpAddress();
- $ipLocation = new IpLocation($ip);
- $ipLocation->lookup();
- return $ipLocation->getCountry();
- }
- function sendSalesLead(){
- $body = "The following person is currently attempting/attempted to signup with Core Commerce.\n\n"
- . "Name: " . $this->getName() . "\n"
- . "Email: " . $this->getEmail() . "\n"
- . "Phone: " . $this->getPhone() . "\n"
- . "Country: " . $this->getMyIpCountry() . "\n"
- . "";
- $to = array();
- $to[] = 'steven.croft@sumeffect.com';
- $to[] = 'kris@sumeffect.com';
- foreach($to as $email){
- mail($email, 'Core Commerce Signup Lead', $body, 'From: sales@corecommerce.com');
- }
- }
- function getMyName(){
- return $this->getFirstName() . ' ' . $this->getLastName();
- }
- function splitNames(){
- $tmp = @explode(' ', $this->getName());
- if(1 == count($tmp)){
- $this->setFirstName($this->getName());
- return;
- }
- $max = (count($tmp)-1);
- $this->setLastName($tmp[$max]);
- unset($tmp[$max]);
- $this->setFirstName(@join(' ', $tmp));
- }
- function getPaypalPreferred(){
- return $this->paypalPreferred;
- }
- function setPaypalPreferred($value){
- $this->paypalPreferred = $value;
- }
- function setReferralID($value){
- $this->referralID = $value;
- }
- function getReferralID(){
- return $this->referralID;
- }
- function setTenPercentReseller($value){
- $this->tenPercentReseller = $value;
- }
- function getTenPercentReseller(){
- return $this->tenPercentReseller;
- }
- function setTenPercentReferralID($value){
- $this->tenPercentReferralID = $value;
- }
- function getTenPercentReferralID(){
- return $this->tenPercentReferralID;
- }
- function getSalesRepFromReferralID(){
- require_once(dirname(__FILE__) . '/ClientDAO.class.php');
- $dao = new ClientDAO();
- return $dao->getSalesRepFromReferralID($this);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment