convertMySQL2NHS() public static méthode

Strings that do not match MySQL date(time) format return $empty_string.
public static convertMySQL2NHS ( string $value, string $empty_string = '-' ) : string
$value string
$empty_string string
Résultat string
Exemple #1
0
    ?>
 column">
			<label for="<?php 
    echo CHtml::modelName($element) . '_' . $field . '_0';
    ?>
">
				<?php 
    echo CHtml::encode($element->getAttributeLabel($field));
    ?>
:
			</label>
		</div>
		<div class="large-<?php 
    echo $layoutColumns['field'];
    ?>
 column end">
<?php 
}
?>

	<?php 
$this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => $name, 'id' => CHtml::modelName($element) . '_' . $field . '_0', 'options' => array_merge($options, array('showAnim' => 'fold', 'dateFormat' => Helper::NHS_DATE_FORMAT_JS)), 'value' => preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value) ? Helper::convertMySQL2NHS($value) : $value, 'htmlOptions' => $htmlOptions));
?>

<?php 
if (!@$htmlOptions['nowrapper']) {
    ?>
		</div>
	</div>
<?php 
}
?>
</div></div>
			<div class="large-10 column end"><div class="data-value"><?php 
echo Yii::app()->format->Ntext($element->message_text);
?>
</div></div>
		</div>
        <?php 
echo $element->comments ? '<hr />' : '';
?>
        <?php 
foreach ($element->comments as $comment) {
    ?>
            <div class="row data-row comment">
                <div class="large-2 column"><div class="data-label">@<?php 
    echo Helper::convertMySQL2NHS($comment->created_date);
    ?>
</div></div>
                <div class="large-10 column end"><div class="data-value"><?php 
    echo Yii::app()->format->Ntext($comment->comment_text);
    ?>
</div></div>
            </div>
        <?php 
}
?>
        <?php 
if ($this->canComment()) {
    ?>
            <div class="<?php 
    echo $this->show_comment_form ? '' : 'hidden';
Exemple #3
0
</a></li>
							<?php 
            }
            ?>
						</ul>
					</div>
				</div>
			</div>
		<?php 
        }
        ?>
		<div class="metadata">
			<span class="info">
				Application sent by <span class="user"><?php 
        echo $email->user->fullname;
        ?>
</span> on <?php 
        echo Helper::convertMySQL2NHS($email->created_date);
        ?>
 at <?php 
        echo date('H:i', strtotime($email->created_date));
        ?>
			</span>
		</div>
	<?php 
    }
} else {
    ?>
	<div class="data-value">N/A</div>
<?php 
}
 protected function appendInjectionValues(&$record, $patient_id, $left_treatment_id = null, $right_treatment_id = null)
 {
     $last_columns = array('last_injection_site', 'last_injection_date', 'last_injection_number');
     if (@$_GET['last_injection']) {
         foreach (array('left', 'right') as $side) {
             #initialise columns
             foreach ($last_columns as $col) {
                 $record[$side . '_' . $col] = 'N/A';
             }
             if ($treatment_id = ${$side . '_treatment_id'}) {
                 $treatment = $this->getTreatment($treatment_id);
                 if (!$treatment || !$treatment->drug_id) {
                     continue;
                 }
                 $command = Yii::app()->db->createCommand()->select('treat.' . $side . '_number as last_injection_number, treat.created_date as last_injection_date, site.name as last_injection_site')->from('et_ophtrintravitinjection_treatment treat')->join('et_ophtrintravitinjection_site insite', 'insite.event_id = treat.event_id')->join('site', 'insite.site_id = site.id')->join('event e', 'e.id = treat.event_id')->join('episode ep', 'e.episode_id = ep.id')->where('e.deleted = 0 and ep.deleted = 0 and ep.patient_id = :patient_id and treat.' . $side . '_drug_id = :drug_id', array(':patient_id' => $patient_id, ':drug_id' => $treatment->drug_id))->order('treat.created_date desc')->limit(1);
                 $res = $command->queryRow();
                 if ($res) {
                     foreach ($last_columns as $col) {
                         $record[$side . '_' . $col] = Helper::convertMySQL2NHS($res[$col], $res[$col]);
                     }
                 }
             }
         }
     }
     if (@$_GET['last_injection']) {
         foreach (array('left', 'right') as $side) {
             $record[$side . '_first_injection_date'] = 'N/A';
             if ($treatment_id = ${$side . '_treatment_id'}) {
                 $treatment = $this->getTreatment($treatment_id);
                 if (!$treatment || !$treatment->drug_id) {
                     continue;
                 }
                 $command = Yii::app()->db->createCommand()->select('treat.created_date as first_injection_date')->from('et_ophtrintravitinjection_treatment treat')->join('event e', 'e.id = treat.event_id')->join('episode ep', 'e.episode_id = ep.id')->where('e.deleted = 0 and ep.deleted = 0 and ep.patient_id = :patient_id and treat.' . $side . '_drug_id = :drug_id', array(':patient_id' => $patient_id, ':drug_id' => $treatment->drug_id))->order('treat.created_date asc')->limit(1);
                 $res = $command->queryRow();
                 if ($res) {
                     $record[$side . '_first_injection_date'] = Helper::convertMySQL2NHS($res['first_injection_date']);
                 }
             }
         }
     }
 }
 /**
  * Returns a date field in NHS format
  *
  * @param string $attribute
  * @param string $empty_string - what to return if not able to convert
  * @return string
  */
 public function NHSDate($attribute, $empty_string = '-')
 {
     if ($value = $this->getAttribute($attribute)) {
         return Helper::convertMySQL2NHS($value, $empty_string);
     }
 }
		</div>
	</div>

	<div class="row data-row">
		<div class="large-6 column">
			<div class="data-label">
				<?php 
echo $pastintervention->getAttributeLabel('end_date');
?>
:
			</div>
		</div>
		<div class="large-6 column">
			<div class="data-value">
				<?php 
echo Helper::convertMySQL2NHS($pastintervention->end_date);
?>
			</div>
		</div>
	</div>

	<div class="row data-row">
		<div class="large-6 column">
			<div class="data-label">
				<?php 
echo $pastintervention->getAttributeLabel('treatment_id');
?>
:
			</div>
		</div>
		<div class="large-6 column">
 /**
  * Ajax action to retrieve the modification data for a given session.
  */
 public function actionGetSessionTimestamps()
 {
     if (isset($_POST['session_id'])) {
         if ($session = Session::model()->findByPk($_POST['session_id'])) {
             $ex = explode(' ', $session->last_modified_date);
             $last_modified_date = $ex[0];
             $last_modified_time = $ex[1];
             $user = User::model()->findByPk($session->last_modified_user_id);
             echo 'Modified on ' . Helper::convertMySQL2NHS($last_modified_date) . ' at ' . $last_modified_time . ' by ' . $user->first_name . ' ' . $user->last_name;
         }
     }
 }
Exemple #8
0
    if ($consultant = $manager->getClinicalConsultant($data)) {
        return $consultant->getFullNameAndTitle();
    } else {
        return '-';
    }
}), array('id' => 'issue_status', 'header' => $dp->getSort()->link('issue_status', 'Status', array('class' => 'sort-link')), 'value' => function ($data) {
    if ($data->event->info) {
        return $data->event->info;
    } else {
        // TODO: possibly don't need this, or this method should handle the above conditional
        return $data->getIssueStatusForDisplay();
    }
}), array('id' => 'issue_date', 'header' => $dp->getSort()->link('issue_date', 'Issue Date', array('class' => 'sort-link')), 'value' => function ($data) {
    $date = $data->getIssueDateForDisplay();
    if ($date) {
        return Helper::convertMySQL2NHS($date);
    }
    return '-';
}), array('id' => 'actions', 'header' => 'Actions', 'class' => 'CButtonColumn', 'htmlOptions' => array('class' => 'left'), 'template' => '<span style="white-space: nowrap;">{view} {edit}</span>', 'viewButtonImageUrl' => false, 'buttons' => array('view' => array('options' => array('title' => 'View CVI', 'class' => ''), 'url' => 'Yii::app()->createURL("/OphCoCvi/Default/view/", array(
                        "id" => $data->event_id))', 'label' => '<button class="secondary small">View</button>'), 'edit' => array('options' => array('title' => 'Add a comment'), 'url' => 'Yii::app()->createURL("/OphCoCvi/Default/update/", array(
                                        "id" => $data->event_id))', 'label' => '<button class="secondary small">Edit</button>', 'visible' => function ($row, $data) {
    return $data->is_draft;
}))));
?>
<h1 class="badge">CVI List</h1>
<div class="box content">
    <?php 
$this->renderPartial('list_filter', array('list_filter' => $list_filter));
?>

    <div class="row">
Exemple #9
0
                        <form>
                            <h4>Session Comments</h4>
                            <textarea rows="2" name="comments_<?php 
echo $session->id;
?>
"
                                      class="comments hidden diaryEditMode"
                                      data-id="<?php 
echo $session->id;
?>
"><?php 
echo CHtml::encode($session['comments']);
?>
</textarea>
                            <?php 
$title = 'Modified on ' . Helper::convertMySQL2NHS($session->last_modified_date) . ' at ' . substr($session->last_modified_date, 13, 5) . ' by ' . $session->session_usermodified->fullName;
?>
                            <p
                                class="comments diaryViewMode"
                                data-id="<?php 
echo $session->id;
?>
"
                                title="<?php 
echo $title;
?>
">
                                <?php 
echo CHtml::encode($session->comments);
?>
                            </p>
Exemple #10
0
							<div class="field-info">
                                Current CVI are as follows:
                                <?php 
if ($current_cvis) {
    $manager = $this->getManager();
    ?>
									<ul>
									<?php 
    foreach ($current_cvis as $cvi_event) {
        ?>
										<li><a href='<?php 
        echo $manager->getEventViewUri($cvi_event);
        ?>
'>
												<?php 
        echo Helper::convertMySQL2NHS($cvi_event->event_date) . ': ' . $manager->getDisplayStatusForEvent($cvi_event);
        ?>
</a>
										</li>
									<?php 
    }
    ?>
									</ul>
								<?php 
}
?>
							</div>
						</div>
                        <div class="field-row">
							<div class="field-info">
                                <a href="<?php 
 /**
  * Returns an associative array of the data values for printing
  */
 public function getStructuredDataForPrint()
 {
     $result = array();
     $result['patientOrRepresentative'] = array(array($this->is_patient ? 'X' : '', ''), array($this->is_patient ? '' : 'X', ''));
     $result['signatureDate'] = \Helper::convertMySQL2NHS($this->signature_date);
     $result['representativeName'] = $this->is_patient ? '' : $this->representative_name;
     return $result;
 }
 column">
	<table class="blank">

	<thead>
	<tr>
		<th>Date</th>
		<th>Time (HH:MM)</th>
	</tr>
	</thead>
	<tbody class="readings-right">
	<tr>
		<td>
			<?php 
    $value = @$this->form_data[$this->form_name]['appointment_date'];
    $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => $this->form_name . '[appointment_date]', 'id' => $this->form_name . '_appointment_date', 'options' => array('showAnim' => 'fold', 'dateFormat' => Helper::NHS_DATE_FORMAT_JS, 'minDate' => 'new Date()'), 'value' => preg_match('/^[0
				-9]{4}-[0-9]{2}-[0-9]{2}$/', $value) ? Helper::convertMySQL2NHS($value) : $value, 'htmlOptions' => null));
    ?>
		</td>
		<td>
			<?php 
    echo CHtml::textField($this->form_name . '[appointment_time]', @$this->form_data[$this->form_name]['appointment_time']);
    ?>
		</td>

	</tr>
	</tbody>
</table>
		</div>

</fieldset>
<?php