Esempio n. 1
0
 public function getFieldValueString($lab_config_id, $tabletype)
 {
     global $con;
     $lab_config_id = mysql_real_escape_string($lab_config_id, $con);
     $field_type = CustomField::getById($this->fieldId, $lab_config_id, $tabletype);
     $field_value = $this->fieldValue;
     if (trim($field_value) == "" || $field_value == null) {
         $field_value = "-";
         return $field_value;
     }
     if ($field_type->fieldTypeId == CustomField::$FIELD_NUMERIC) {
         $range = $field_type->getFieldRange();
         return $field_value . " {$range['2']}";
     } else {
         if ($field_type->fieldTypeId == CustomField::$FIELD_DATE) {
             return DateLib::mysqlToString($field_value);
         } else {
             return $field_value;
         }
     }
 }
Esempio n. 2
0
 /**
  * @depends testCreateAndGetUserById
  */
 public function testDeleteUserCascadesToDeleteEverythingItShould()
 {
     $group = new Group();
     $group->name = 'Os mais legais do Rio';
     $this->assertTrue($group->save());
     $user = new User();
     $user->username = '******';
     $user->title->value = 'Senhor';
     $user->firstName = 'José';
     $user->lastName = 'Olivereira';
     $user->jobTitle = 'Traficante';
     $user->primaryAddress->street1 = 'R. das Mulheres, 69';
     $user->primaryAddress->street2 = '';
     $user->primaryAddress->city = 'Centro';
     $user->primaryAddress->state = 'RJ';
     $user->primaryAddress->postalCode = '';
     $user->primaryAddress->country = 'Brasil';
     $user->primaryEmail->emailAddress = '*****@*****.**';
     $user->primaryEmail->optOut = 1;
     $user->primaryEmail->isInvalid = 0;
     $user->manager = User::getByUsername('bill');
     $user->setPassword('Senhor');
     $user->groups->add($group);
     $user->save();
     $this->assertTrue($user->save());
     $titleId = $user->title->id;
     $primaryAddressId = $user->primaryAddress->id;
     $primaryEmailId = $user->primaryEmail->id;
     $groupId = $group->id;
     $user->delete();
     unset($user);
     unset($group);
     Group::getById($groupId);
     User::getByUsername('bill');
     try {
         CustomField::getById($titleId);
         $this->fail("Title should have been deleted.");
     } catch (NotFoundException $e) {
     }
     try {
         Address::getById($primaryAddressId);
         $this->fail("Address should have been deleted.");
     } catch (NotFoundException $e) {
     }
     try {
         Email::getById($primaryEmailId);
         $this->fail("Email should have been deleted.");
     } catch (NotFoundException $e) {
     }
 }
Esempio n. 3
0
	public function getCustomFieldEditForm($field_id, $lab_config_id, $type)
	{
		# Returns HTML form fields for editing a custom field
		# $type = 1 for specimen custom field
		# $type = 2 for patient custom field
		# $type = 3 for labtitle custom field
		$custom_field = CustomField::getById($field_id, $lab_config_id, $type);
		if($custom_field == null)
		{
			?>
			<div class='sidetip_nopos'>
			<?php echo LangUtil::$generalTerms['MSG_NOTFOUND']; ?>
			</div>
			<?php
			return;
		}
		
		?>
		<input type='hidden' name='id' value='<?php echo $custom_field->id; ?>'></input>
		<input type='hidden' name='lid' value='<?php echo $lab_config_id; ?>'></input>
		<input type='hidden' name='t' value='<?php echo $type; ?>'></input>
		<table>
			<tbody>
				<tr valign='top'>
					<td>
						<?php echo LangUtil::$generalTerms['NAME']; ?>&nbsp;&nbsp;&nbsp;
					</td>
					<td>
						<input type='input' id='fname' name='fname' value='<?php echo $custom_field->fieldName; ?>' class='uniform_width'>
						</input>
					</td>
				</tr>
				<tr valign='top'>
					<td>
						<?php echo LangUtil::$generalTerms['TYPE']; ?>
					</td>
					<td>
						<input type='hidden' id='ftype' name='ftype' value='<?php echo $custom_field->fieldTypeId; ?>'></input>
						<?php echo $custom_field->getFieldTypeName(); ?>
					</td>
				</tr>
				<?php
				if($custom_field->fieldTypeId == CustomField::$FIELD_OPTIONS || $custom_field->fieldTypeId == CustomField::$FIELD_MULTISELECT)
				{
					?>
					<tr valign='top'>
						<td>
							<?php echo LangUtil::$generalTerms['OPTIONS']; ?>
						</td>
						<td>
						<span id='options_list'>
					<?php
					# Show existing options with fields to add new options
					$options = $custom_field->getFieldOptions();
					$count = 1;
					foreach($options as $option)
					{
						?>
						<input type='text' name='option[]' value='<?php echo $option; ?>' class='uniform_width'>
						</input>
						<br>
						<?php
					}
					?>
						</span>
						<small><a href='javascript:appendoption();'><?php echo LangUtil::$generalTerms['ADDANOTHER']; ?> &raquo;</a></small>
						</td>
					</tr>
					<?php
				}
				if($custom_field->fieldTypeId == CustomField::$FIELD_NUMERIC)
				{
					# Show existing range value fields
					$range = $custom_field->getFieldRange();
					?>
					<tr valign='top'>
						<td>
							<?php echo LangUtil::$generalTerms['RANGE']; ?>
						</td>
						<td>
							<input type='text' value='<?php echo $range[0]; ?>' name='range_lower' id='range_lower' size='5'></input>
							-
							<input type='text' value='<?php echo $range[1]; ?>' name='range_upper' id='range_upper' size='5'></input>
						</td>
					</tr>
					<tr valign='top' id='unit_row'>
						<td>
							<?php echo LangUtil::$generalTerms['UNIT']; ?>
						</td>
						<td>
							<input type='text' value='<?php echo $range[2]; ?>' name='unit' id='unit' class='uniform_width'></input>
						</td>
					</tr>
					<?php
				}
				?>
				<tr>
					<td>
					Enable:
					</td>
					<td>
					
					<input type="checkbox" name="Enable" value="enable" <?php if(($custom_field->flag)==0) { ?> checked <?php }?> >
					</td>
				</tr>
				<tr>
					<td>
					Delete:
					</td>
					<td>
					<input type="checkbox" name="Delete" id="Delete" value="Delete" >
					</td>
				</tr>
				<tr>
				<td>
				<input type='hidden' id='flag' name='flag' value='<?php echo $custom_field->flag; ?>'></input>
				</td>
				</tr>
				<tr>
					<td></td>
					<td>
					<br>
					<input type='button' id='cfield_edit_button' value='<?php echo LangUtil::$generalTerms['CMD_SUBMIT']; ?>' onclick='javascript:checkandsubmit()'>
					</input>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<small><a href='lab_config_home.php?id=<?php echo $lab_config_id; ?>&show_f=1'><?php echo LangUtil::$generalTerms['CMD_CANCEL']; ?></a></small>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<span id='cfield_progress_spinner' style='display:none;'>
						<?php $this->getProgressSpinner(LangUtil::$generalTerms['CMD_SUBMITTING']); ?>
					</span>
					</td>
				</tr>
				<tr>
					<td></td>
					<td>
						<br>
						<div id='err_msg' class='clean-error uniform_width' style='display:none;'>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
		<?php
	}
Esempio n. 4
0
 public function testDeleteContactCascadesToDeleteEverythingItShould()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $this->assertEquals(6, count(ContactState::GetAll()));
     $manager = UserTestHelper::createBasicUser('Godzilla');
     $this->assertTrue($manager->save());
     $account = new Account();
     $account->name = 'Os Drogas Mais Legais';
     $this->assertTrue($account->save());
     $contact = new Contact();
     $contact->title->value = 'Senhor';
     $contact->firstName = 'José';
     $contact->lastName = 'Olivereira';
     $contact->jobTitle = 'Traficante';
     $contact->primaryAddress->street1 = 'R. das Mulheres, 69';
     $contact->primaryAddress->street2 = '';
     $contact->primaryAddress->city = 'Centro';
     $contact->primaryAddress->state = 'RJ';
     $contact->primaryAddress->postalCode = '';
     $contact->primaryAddress->country = 'Brasil';
     $contact->primaryEmail->emailAddress = '*****@*****.**';
     $contact->primaryEmail->optOut = 1;
     $contact->primaryEmail->isInvalid = 0;
     $contact->secondaryAddress->street1 = 'Passagem do Comando Vermelho';
     $contact->secondaryAddress->street2 = '';
     $contact->secondaryAddress->city = 'Complexo do Alemão';
     $contact->secondaryAddress->state = 'RJ';
     $contact->secondaryAddress->postalCode = '';
     $contact->secondaryAddress->country = 'Brasil';
     $contact->account = $account;
     $contact->state->name = 'Novo Hermão';
     $contact->state->order = 6;
     $this->assertTrue($contact->save());
     $titleId = $contact->title->id;
     $primaryAddressId = $contact->primaryAddress->id;
     $primaryEmailId = $contact->primaryEmail->id;
     $secondaryAddressId = $contact->secondaryAddress->id;
     $accountId = $account->id;
     $stateId = $contact->state->id;
     $this->assertEquals(7, count(ContactState::GetAll()));
     //new state created. Confirm this
     $contact->delete();
     unset($contact);
     unset($manager);
     unset($account);
     User::getByUsername('godzilla');
     Account::getById($accountId);
     ContactState::getById($stateId);
     try {
         CustomField::getById($titleId);
         $this->fail("Title should have been deleted.");
     } catch (NotFoundException $e) {
     }
     try {
         Address::getById($primaryAddressId);
         $this->fail("Primary address should have been deleted.");
     } catch (NotFoundException $e) {
     }
     try {
         Email::getById($primaryEmailId);
         $this->fail("Primary email should have been deleted.");
     } catch (NotFoundException $e) {
     }
     try {
         Address::getById($secondaryAddressId);
         $this->fail("Secondary address should have been deleted.");
     } catch (NotFoundException $e) {
     }
 }