Skip to content

Instantly share code, notes, and snippets.

@rtgibbons
Created December 9, 2010 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtgibbons/735394 to your computer and use it in GitHub Desktop.
Save rtgibbons/735394 to your computer and use it in GitHub Desktop.
<?php
function add() {
if (!$this->Session->check('location')) {
$this->Session->setFlash(__('Need to enter your location ID and password first'));
$this->redirect(array('action' => 'signin'));
} else {
//set data from session to pre-populate form
$location = $this->Session->read('location.Segmentation');
pr($location);
if (!empty($this->data)) {
$this->Signup->create();
$this->data['Signup']['companyInfo'] = json_encode($this->data['Signup']['companyInfo']);
$this->data['Signup']['primaryContact'] = json_encode($this->data['Signup']['primaryContact']);
$this->data['Signup']['TTE'] = json_encode($this->data['Signup']['TTE']);
$this->data['Signup']['PO'] = json_encode($this->data['Signup']['PO']);
$this->data['Signup']['DS'] = json_encode($this->data['Signup']['DS']);
$this->data['Signup']['PB'] = json_encode($this->data['Signup']['PB']);
if ($this->Signup->save($this->data)) {
$this->Session->setFlash(__('The signup has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The signup could not be saved. Please, try again.', true));
}
} else {
$this->data['Signup']['particpateLevel'] = $location['segment'];
$this->data['Signup']['salesConsultant'] = $location['consultant'];
$this->data['Signup']['companyInfo']['doctorName'] = $location['practice_label'];
$this->data['Signup']['companyInfo']['practiceName'] = $location['location_name'];
$this->data['Signup']['companyInfo']['address1'] = $location['address_line_1'];
$this->data['Signup']['companyInfo']['address2'] = $location['address_line_2'];
$this->data['Signup']['companyInfo']['city'] = $location['city'];
$this->data['Signup']['companyInfo']['state'] = $location['state'];
$this->data['Signup']['companyInfo']['zip'] = $location['zip_code'];
$this->data['Signup']['primaryContact']['phone'] = $location['telephone'];
$this->data['Signup']['primaryContact']['email'] = $location['email'];
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment