The followings are the available columns in table 'contact_label':
Inheritance: extends BaseActiveRecordVersioned
 /**
  * @covers ContactLabel::staffType
  */
 public function testStaffType()
 {
     Yii::app()->session['selected_site_id'] = 1;
     $result = $this->model->staffType();
     $expected = 'Moorfields staff';
     $this->assertEquals($expected, $result);
 }
Example #2
0
			<div class="large-2 column">
				<label for="q">Search:</label>
			</div>
			<div class="large-4 column end">
				<?php 
echo CHtml::textField('q', @$_GET['q']);
?>
			</div>
		</div>
		<div class="row field-row">
			<div class="large-2 column">
				<label for="label">Label:</label>
			</div>
			<div class="large-4 column end">
				<?php 
echo CHtml::dropDownList('label', @$_GET['label'], CHtml::listData(ContactLabel::model()->active()->findAll(array('order' => 'name')), 'id', 'name'), array('empty' => '- Any label -'));
?>
			</div>
		</div>
		<div class="row field-row">
			<div class="large-4 large-offset-2 column end">
				<?php 
echo EventAction::button('Search', 'search', array(), array('class' => 'small'))->toHtml();
?>
				<img src="<?php 
echo Yii::app()->assetManager->createUrl('img/ajax-loader.gif');
?>
" class="loader" alt="loading..." style="display: none;" />
			</div>
		</div>
	</form>
 public function actionAddContact()
 {
     if (@$_POST['site_id']) {
         if (!($site = Site::model()->findByPk($_POST['site_id']))) {
             throw new Exception("Site not found: " . $_POST['site_id']);
         }
     } else {
         if (!($institution = Institution::model()->findByPk(@$_POST['institution_id']))) {
             throw new Exception("Institution not found: " . @$_POST['institution_id']);
         }
     }
     if (!($patient = Patient::model()->findByPk(@$_POST['patient_id']))) {
         throw new Exception("patient required for contact assignment");
     }
     // Attempt to de-dupe by looking for an existing record that matches the user's input
     $criteria = new CDbCriteria();
     $criteria->compare('lower(title)', strtolower($_POST['title']));
     $criteria->compare('lower(first_name)', strtolower($_POST['first_name']));
     $criteria->compare('lower(last_name)', strtolower($_POST['last_name']));
     if (isset($site)) {
         $criteria->compare('site_id', $site->id);
     } else {
         $criteria->compare('institution_id', $institution->id);
     }
     if ($contact = Contact::model()->with('locations')->find($criteria)) {
         foreach ($contact->locations as $location) {
             $pca = new PatientContactAssignment();
             $pca->patient_id = $patient->id;
             $pca->location_id = $location->id;
             if (!$pca->save()) {
                 throw new Exception("Unable to save patient contact assignment: " . print_r($pca->getErrors(), true));
             }
             $this->redirect(array('/patient/view/' . $patient->id));
         }
     }
     $contact = new Contact();
     $contact->attributes = $_POST;
     if (@$_POST['contact_label_id'] == 'nonspecialty') {
         if (!($label = ContactLabel::model()->findByPk(@$_POST['label_id']))) {
             throw new Exception("Contact label not found: " . @$_POST['label_id']);
         }
     } else {
         if (!($label = ContactLabel::model()->find('name=?', array(@$_POST['contact_label_id'])))) {
             throw new Exception("Contact label not found: " . @$_POST['contact_label_id']);
         }
     }
     $contact->contact_label_id = $label->id;
     if (!$contact->save()) {
         throw new Exception("Unable to save contact: " . print_r($contact->getErrors(), true));
     }
     $cl = new ContactLocation();
     $cl->contact_id = $contact->id;
     if (isset($site)) {
         $cl->site_id = $site->id;
     } else {
         $cl->institution_id = $institution->id;
     }
     if (!$cl->save()) {
         throw new Exception("Unable to save contact location: " . print_r($cl->getErrors(), true));
     }
     $pca = new PatientContactAssignment();
     $pca->patient_id = $patient->id;
     $pca->location_id = $cl->id;
     if (!$pca->save()) {
         throw new Exception("Unable to save patient contact assignment: " . print_r($pca->getErrors(), true));
     }
     $this->redirect(array('/patient/view/' . $patient->id));
 }
 public function actionDeleteContactLabel()
 {
     if (!($contactlabel = ContactLabel::model()->findByPk(@$_POST['contact_label_id']))) {
         throw new Exception("ContactLabel not found: " . @$_POST['contact_label_id']);
     }
     $count = Contact::model()->count('contact_label_id=?', array($contactlabel->id));
     if ($count == 0) {
         if (!$contactlabel->delete()) {
             throw new Exception("Unable to delete ContactLabel: " . print_r($contactlabel->getErrors(), true));
         }
         Audit::add('admin-ContactLabel', 'delete', @$_POST['contact_label_id']);
     }
     echo $count;
 }
							</div>
						</div>

						<div class="row field-row contactLabel">
							<div class="<?php 
    echo $form->columns('label');
    ?>
">
								<label for="label_id">Label:</label>
							</div>
							<div class="<?php 
    echo $form->columns('field');
    ?>
">
								<?php 
    echo CHtml::dropDownList('label_id', '', CHtml::listData(ContactLabel::model()->active()->findAll(array('order' => 'name')), 'id', 'name'), array('empty' => '- Select -'));
    ?>
							</div>
						</div>

						<div class="row field-row">
							<div class="<?php 
    echo $form->columns('label');
    ?>
">
								<label for="title">Title:</label>
							</div>
							<div class="<?php 
    echo $form->columns('field');
    ?>
">
Example #6
0
 /**
  * Searches for contacts with the given criteria
  *
  * string $term - string to search Contact last name - will do exact match so provide wild cards as required
  * string $label - the exact label string to match on.
  * boolean $exclude - if true, search for all contacts without the given label. otherwise only that label
  * string $join - table to join on to force only matches of that contact type. Currently only supports person
  */
 public function findByLabel($term, $label, $exclude = false, $join = null)
 {
     if (!($cl = ContactLabel::model()->find('name=?', array($label)))) {
         throw new Exception("Unknown contact label: {$label}");
     }
     $contacts = array();
     $criteria = new CDbCriteria();
     $criteria->addSearchCondition('lower(last_name)', $term, false);
     if ($exclude) {
         $criteria->compare('contact_label_id', '<>' . $cl->id);
     } else {
         $criteria->compare('contact_label_id', $cl->id);
     }
     $criteria->order = 'title, first_name, last_name';
     if ($join) {
         if (!in_array($join, array('person'))) {
             throw new Exception('Unknown join table ' . $join);
         }
         // force to only match on Person contacts
         $criteria->join = 'join ' . $join . ' model_join on model_join.contact_id = t.id';
     }
     $found_contacts = Contact::model()->with(array('locations' => array('with' => array('site', 'institution')), 'label'))->findAll($criteria);
     foreach ($found_contacts as $contact) {
         if ($contact->locations) {
             foreach ($contact->locations as $location) {
                 $contacts[] = array('line' => $contact->contactLine($location), 'contact_location_id' => $location->id);
             }
         } else {
             $contacts[] = array('line' => $contact->contactLine(), 'contact_id' => $contact->id);
         }
     }
     return $contacts;
 }
Example #7
0
echo $form->textField($contact, 'first_name', array('autocomplete' => Yii::app()->params['html_autocomplete']));
?>
		<?php 
echo $form->textField($contact, 'last_name', array('autocomplete' => Yii::app()->params['html_autocomplete']));
?>
		<?php 
echo $form->textField($contact, 'nick_name', array('autocomplete' => Yii::app()->params['html_autocomplete']));
?>
		<?php 
echo $form->textField($contact, 'primary_phone', array('autocomplete' => Yii::app()->params['html_autocomplete']));
?>
		<?php 
echo $form->textField($contact, 'qualifications', array('autocomplete' => Yii::app()->params['html_autocomplete']));
?>
		<?php 
echo $form->dropDownList($contact, 'contact_label_id', CHtml::listData(ContactLabel::model()->active()->findAll(array('order' => 'name')), 'id', 'name'), array('empty' => '- None -'));
?>

		<?php 
/* TODO */
?>
		<div class="row field-row hide">
			<div class="large-5 large-offset-2 column">
				<?php 
echo EventAction::button('Add label', 'add_label', array(), array('class' => 'small'))->toHtml();
?>
			</div>
		</div>
		<?php 
/* TODO */
?>