/**
  * Edits or adds a Procedure.
  *
  * @param bool|int $id
  *
  * @throws CHttpException
  */
 public function actionEdit($id = false)
 {
     $admin = new Admin(FormularyDrugs::model(), $this);
     if ($id) {
         $admin->setModelId($id);
     }
     $admin->setModelDisplayName('Formulary Drugs');
     $criteria = new CDbCriteria();
     $admin->setEditFields(array('id' => 'label', 'name' => 'text', 'type_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugType::model()->findAll(), 'id', 'name'), 'htmlOptions' => null, 'hidden' => false, 'layoutColumns' => null), 'aliases' => 'text', 'tallman' => 'text', 'form_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugForm::model()->findAll(), 'id', 'name'), 'htmlOptions' => null, 'hidden' => false, 'layoutColumns' => null), 'dose_unit' => 'text', 'default_dose' => 'text', 'default_route_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugRoute::model()->findAll(), 'id', 'name'), 'htmlOptions' => array('empty' => '-- Please select --'), 'hidden' => false, 'layoutColumns' => null), 'default_frequency_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugFrequency::model()->findAll(), 'id', 'name'), 'htmlOptions' => array('empty' => '-- Please select --'), 'hidden' => false, 'layoutColumns' => null), 'default_duration_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugDuration::model()->findAll(), 'id', 'name'), 'htmlOptions' => array('empty' => '-- Please select --'), 'hidden' => false, 'layoutColumns' => null), 'preservative_free' => 'checkbox', 'active' => 'checkbox', 'allergy_warnings' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'Allergy Warnings', 'options' => CHtml::encodeArray(CHtml::listData(Allergy::model()->findAll($criteria->condition = "name != 'Other'"), 'id', 'name')))));
     $admin->editModel();
 }
Exemplo n.º 2
0
 /**
  * Edits or adds a Procedure.
  *
  * @param bool|int $id
  *
  * @throws CHttpException
  */
 public function actionEdit($id = false)
 {
     $admin = new Admin(Procedure::model(), $this);
     if ($id) {
         $admin->setModelId($id);
     }
     $admin->setEditFields(array('term' => 'text', 'short_format' => 'text', 'default_duration' => 'text', 'snomed_code' => 'text', 'snomed_term' => 'text', 'aliases' => 'text', 'unbooked' => 'checkbox', 'active' => 'checkbox', 'opcsCodes' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'OPCS Code', 'options' => CHtml::encodeArray(CHtml::listData(OPCSCode::model()->findAll(), 'id', function ($model) {
         return $model->name . ': ' . $model->description;
     }))), 'benefits' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'Benefit', 'options' => CHtml::encodeArray(CHtml::listData(Benefit::model()->findAll(), 'id', 'name'))), 'complications' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'Complication', 'options' => CHtml::encodeArray(CHtml::listData(Complication::model()->findAll(), 'id', 'name')))));
     if (isset($admin->getModel()->operationNotes)) {
         $admin->setEditFields(array_merge($admin->getEditFields(), array('operationNotes' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'Operation Note Element', 'options' => CHtml::encodeArray(CHtml::listData(ElementType::model()->findAllByAttributes(array(), 'event_type_id in (select id from event_type where name = "Operation Note")'), 'id', 'name'))))));
     }
     $admin->editModel();
 }
Exemplo n.º 3
0
 /**
  * Checking the search term if it is a NHS number, Hospital number or Patient name.
  *
  * @param string $term
  */
 public function parseTerm($term)
 {
     $term = trim($term);
     $search_terms = array('hos_num' => null, 'nhs_num' => null, 'first_name' => null, 'last_name' => null);
     // NHS number
     if ($nhs = $this->getNHSnumber($term)) {
         $search_terms['nhs_num'] = $nhs;
         // Hospital number (assume a < 10 digit number is a hosnum)
     } elseif ($hos_num = $this->getHospitalNumber($term)) {
         $search_terms['hos_num'] = $hos_num;
         // Patient name
     } elseif ($name = $this->getPatientName($term)) {
         $search_terms['first_name'] = trim($name['first_name']);
         $search_terms['last_name'] = trim($name['last_name']);
     }
     $this->searchTerms = CHtml::encodeArray($search_terms);
     return $this->searchTerms;
 }
Exemplo n.º 4
0
 public function actionImport()
 {
     $data = CHtml::encodeArray($_POST);
     //检查文章标题
     $news = News::model()->findByAttributes(array('title' => $data['title']));
     if (!empty($news)) {
         die('文章已存在');
     } else {
         $data['content'] = NewsService::instance()->ubb2html($data['content']);
         $news = new News();
         $news->attributes = array('title' => $data['title'], 'description' => mb_substr(trim(strip_tags($data['content'])), 0, 20, 'UTF-8'), 'thumb' => $data['thumb'], 'content' => $data['content'], 'wechat' => $data['wechat'], 'created_at' => strtotime($data['created_at']), 'category_id' => $data['category_id'], 'collected_at' => time());
         $news->save();
         if (empty($news->errors)) {
             echo 1;
         } else {
             $error = array_shift($news->errors);
             echo $error[0];
         }
     }
 }
Exemplo n.º 5
0
            ?>
		</td><td>
		<?php 
            echo CHtml::activeCheckBox($repParam, "[{$n}]allowCustomer");
            ?>
		</td><td>
		<?php 
            echo CHtml::activeCheckBox($repParam, "[{$n}]allowNotes");
            ?>
		</td><td>
		<?php 
            echo CHtml::activeCheckBox($repParam, "[{$n}]isFinalBalance");
            ?>
		</td><td>
			<?php 
            $accounts = CHtml::encodeArray(CHtml::listData(Account::model()->findAll(array('join' => ' LEFT JOIN TemplateRowAccount ON t.id=TemplateRowAccount.accountId', 'select' => 't.id as id, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code', 'condition' => 'templateRowId=' . $repParam->id)), 'id', 'name'));
            $accounts[0] = '-- ' . ' ' . ' --';
            echo CHtml::activeDropDownList($repParam, "[{$n}]defaultAccountId", $accounts, array('title' => Yii::t('lazy8', 'contexthelp.template.defaultAccountId')));
            echo CHtml::submitButton(Yii::t('lazy8', 'edit'), array('name' => "editrow[{$n}]", 'title' => Yii::t('lazy8', 'contexthelp.template.edit')));
            ?>
		</td><td>
		<?php 
            echo CHtml::activeTextField($repParam, "[{$n}]defaultValue", array('size' => 8));
            ?>
		</td><td>
		<?php 
            echo CHtml::activeTextField($repParam, "[{$n}]phpFieldCalc", array('size' => 8));
            ?>
		</td><td>
		<?php 
            echo CHtml::submitButton(Yii::t('lazy8', 'Remove Row'), array('name' => "deleterow[{$n}]", 'title' => Yii::t('lazy8', 'contexthelp.Remove Row')));
    $accountList = ' AND id IN (' . $accountID_string . ')';
}
$sqlList = CHtml::encodeArray(CHtml::listData(Account::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId') . $accountList, 'select' => 'CONCAT(\'AND Account.id=\',id) as  id, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'id', 'name'));
$sqlList[''] = '';
// ********************************************************
$accountList = '';
if (Yii::app()->user->name == "ReportsOnlyUser") {
    $accountNumbers = Yii::app()->session['accountNumbers'];
    if (strpos($accountNumbers, '101059') == false) {
        $accountNumbers .= ',101059';
    }
    $accountList = ' AND code IN (' . $accountNumbers . ')';
}
$sqlList = CHtml::encodeArray(CHtml::listData(Account::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId') . $accountList, 'select' => 'CONCAT(\'AND Account.id=\',id) as id, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'id', 'name'));
$sqlList[''] = '';
// ***********************************
$accountList = '';
if (Yii::app()->user->name == "ReportsOnlyUser") {
    $accountNumbers = Yii::app()->session['accountNumbers'];
    if (strpos($accountNumbers, '101059') == false) {
        $accountNumbers .= ',101059';
    }
    $accountList = ' AND code IN (' . $accountNumbers . ')';
}
$sqlList = CHtml::encodeArray(CHtml::listData(Account::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId') . $accountList, 'select' => 'CONCAT(\'AND Account.code=\',code) as code, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'code', 'name'));
$sqlList[''] = '';
$sqlList = CHtml::encodeArray(CHtml::listData(Account::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId'), 'select' => 'CONCAT(\'AND Account.id=\',id) as  id, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'id', 'name'));
$sqlList[''] = '';
?>

Exemplo n.º 7
0
 /**
  * Builds the dropdown for saved webforms
  * @return html constructed HTML
  */
 public function getDropDown()
 {
     array_unshift($this->formAttrs, array('id' => '0', 'name' => '------------'));
     $html = CHtml::dropDownList('saved-forms', '', CHtml::encodeArray(CHtml::listData($this->formAttrs, 'id', 'name')), array('class' => 'left'));
     return $html;
 }
 * You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>.
 *
 * @link http://www.openeyes.org.uk
 *
 * @author OpenEyes <*****@*****.**>
 * @copyright Copyright (c) 2008-2011, Moorfields Eye Hospital NHS Foundation Trust
 * @copyright Copyright (c) 2011-2013, OpenEyes Foundation
 * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0
 */
if (isset($_POST['comorbidities_items_valid']) && $_POST['comorbidities_items_valid']) {
    $item_ids = @$_POST['comorbidities_items'];
} else {
    $item_ids = $element->getItemIds();
}
?>
<div class="sub-element-fields">
	<?php 
echo CHtml::hiddenField('comorbidities_items_valid', 1, array('id' => 'comorbidities_items_valid'));
?>
	<div class="field-row comorbidities-multi-select">
		<?php 
echo $form->multiSelectList($element, CHtml::modelName($element) . '[items]', 'items', 'id', CHtml::encodeArray(CHtml::listData(OEModule\OphCiExamination\models\OphCiExamination_Comorbidities_Item::model()->activeOrPk($element->comorbidityItemValues)->bySubspecialty($this->firm->getSubspecialty())->findAll(), 'id', 'name')), array(), array('empty' => '-- Add --', 'label' => 'Comorbidities', 'nowrapper' => true), false, true, 'No comorbidities', true, true);
?>
	</div>
	<div class="field-row">
		<?php 
echo $form->textArea($element, 'comments', array('rows' => '1', 'cols' => '80', 'class' => 'autosize', 'nowrapper' => true), false, array('placeholder' => 'Enter comments here'));
?>
	</div>
</div>
Exemplo n.º 9
0
}
//var_dump($arr);
echo $form->dropDownList($model, 'year', CHtml::encodeArray($arr));
?>
</td>
<td>

		<?php 
echo $form->label($model, 'month');
?>
</td>

<td>

    <?php 
echo $form->dropDownList($model, 'month', CHtml::encodeArray(Yii::app()->locale->getMonthNames()));
?>
 </td>
 <td style="padding: 0px 20px 0px 20px;">
           
             <?php 
echo $form->labelEx($model, 'm_short_code');
?>
        </td>
        <td>
            <?php 
$options = array();
$sql = "SELECT DISTINCT short_code from sdp.sdp_services order by short_code";
foreach (Yii::app()->db->createCommand($sql)->queryAll() as $row) {
    $options[$row['short_code']] = $row['short_code'];
}
Exemplo n.º 10
0
 private function addError($error)
 {
     $this->r['errors'][] = is_array($error) ? CHtml::encodeArray($error) : CHtml::encode($error);
     return false;
 }
<?php

/**
 * OpenEyes
 *
 * (C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011
 * (C) OpenEyes Foundation, 2011-2013
 * This file is part of OpenEyes.
 * OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>.
 *
 * @package OpenEyes
 * @link http://www.openeyes.org.uk
 * @author OpenEyes <*****@*****.**>
 * @copyright Copyright (c) 2008-2011, Moorfields Eye Hospital NHS Foundation Trust
 * @copyright Copyright (c) 2011-2013, OpenEyes Foundation
 * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0
 */
?>
<div class="sub-element-fields">
	<div class="field-row furtherfindings-multi-select">
		<?php 
echo $form->multiSelectListFreeText($element, CHtml::modelName($element) . '[further_findings_assignment]', 'further_findings_assignment', 'finding_id', CHtml::encodeArray(CHtml::listData(Finding::model()->activeOrPk($element->furtherFindingsAssigned)->bySubspecialty($this->firm->getSubspecialty())->findAll(), 'id', 'name')), array(), array('empty' => '-- Add --', 'label' => 'Findings', 'nowrapper' => true, 'requires_description_field' => 'requires_description'), false, true, 'No further findings', true, true, array(), 'Finding');
?>
	</div>
</div>
 public function getListChanges($project_id)
 {
     $result = Yii::app()->db->createCommand()->select('CONCAT("/' . self::$file_path . '/",file)  as `file`, file as `filename`, comment, id, moderate, date_create')->from(self::tableName())->where('project_id =' . (int) $project_id . (User::model()->isAuthor() ? ' AND moderate=1' : ''))->queryAll();
     return CHtml::encodeArray($result);
 }
Exemplo n.º 13
0
    <div class="cell" style="width:400px;">
        <div style="margin-bottom: 1em;">
            <h4><?php 
echo Yii::t('marketing', 'Saved Forms') . ':';
?>
</h4>
            <div class="row">
                <p class="fieldhelp-above" style="width: auto;">
                    <?php 
echo Yii::t('marketing', 'Choose an existing form as a starting point.');
?>
                </p>
                <?php 
// so the dropdown will have a blank choice
array_unshift($formAttrs, array('id' => '0', 'name' => '------------'));
echo CHtml::dropDownList('saved-forms', '', CHtml::encodeArray(CHtml::listData($formAttrs, 'id', 'name')), array('class' => 'left'));
echo CHtml::button(Yii::t('marketing', 'Reset Form'), array('id' => 'reset-form', 'class' => 'x2-button x2-small-button'));
/*echo CHtml::button (
  Yii::t('marketing','Delete Form'),
  array(
      'id' => 'delete-form',
      'class'=>'x2-button x2-small-button',
      'style' => 'display: none;' 
  )); */
?>
            </div>
        </div>
    </div>

    <?php 
echo CHtml::beginForm('', 'post', array('id' => 'web-form-designer-form'));
 public function getListChanges($project_id)
 {
     $result = Yii::app()->db->createCommand()->select('CONCAT("/' . self::$file_path . '/",file)  as `file`, file as `filename`, comment, id, moderate, date_create')->from($this->tableName())->where('project_id =' . (int) $project_id . (User::model()->isManager() || User::model()->isAdmin() ? '' : ' AND (user_id = ' . Yii::app()->user->id . ' OR moderate=1)'))->queryAll();
     return CHtml::encodeArray($result);
 }
Exemplo n.º 15
0
echo $form->labelEx($model, 'number_of_offence');
?>
            <?php 
echo $form->textField($model, 'number_of_offence', array('value' => 0, 'span' => 5, 'disabled' => true, 'style' => 'font-weight: bold;color:red'));
?>
        </div>  
        <div class="row1" style="margin-bottom:10px;width:700px !important;">
            <div style="float:left;width:700px !important;height:auto;" >
                    <span>List of Offences</span>
                    <span style="margin-left:280px">Offence Commited</span>
                    <?php 
//echo $form->labelEx($model,'offence_ids');
?>
    
                    <?php 
echo $form->dropDownList($model, 'offence_ids[]', CHtml::encodeArray(CHtml::listData(OffenceList::model()->findAll(array('order' => 'id ASC')), 'id', 'fullOffence')), array('options' => $model->user_challan_list(), 'multiple' => 'multiple'), array('style' => 'width:700px !important;height:auto'));
?>
 
                    <?php 
//echo "<pre>";print_r($model->user_challan_list());
//print_r(array('1'=>array('selected'=>true),'2'=>array('selected'=>true)));
?>
                <div style="clear:both;" >
                </div>
            </div>
        </div>
        <div class="row" style="margin-bottom:10px;margin-top:80px;">
            <h4 style="background-color: #49afcd;
    background-image: linear-gradient(to bottom, #5bc0de, #2f96b4);color:#E7FDD6 !important;padding: 6px;background-image: linear-gradient(to bottom, #3AE8EB, #0e8eff) repeat-x scroll 0 0 #335a84; background-repeat: repeat-x;

    border-radius: 4px;
Exemplo n.º 16
0
echo CHtml::activeLabelEx($model, 'accountTypeId', array('class' => 'help', 'title' => Yii::t('lazy8', 'contexthelp.accountTypeId'), 'onclick' => 'alert(this.title)'));
echo CHtml::activeDropDownList($model, 'accountTypeId', CHtml::listData(AccountType::model()->findAll(array('order' => 'isInBalance DESC, sortOrder', 'condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId'))), 'id', 'name'), array('onchange' => 'check(\'AccountEmail\');'));
?>
</div>

<?php 
if ($update) {
    ?>
	<center>
		<div class="selectTag" style="width: 90%;margin: 1em;">

			<div style="font-weight: bold;text-align: center;margin-bottom: 1em;">Add a tag to this account: </div>

			<div class="tagList" style="float: left;margin-bottom: 1em;">
				<?php 
    echo CHtml::dropDownList('AddTagToAccount', 'customerId', CHtml::encodeArray(CHtml::listData(Customer::model()->findAll(array('condition' => 'companyId=' . Yii::app()->user->getState('selectedCompanyId'), 'select' => 'id, CAST(CONCAT(code, ": " ,name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'id', 'name')));
    ?>
			 </div>
				
			<div>
				<a href="#" class="add_tag btn" data-account="<?php 
    echo $model->id;
    ?>
" style="float: right;">+ Add tag</a>
			</div>
		</div>
	</center>

	<center>
		<div style="width: 90%;margin: 1em;clear:both">
			<div style="font-weight: bold;margin-bottom: 1em">Tags Associated with this account</div>
Exemplo n.º 17
0
 public function actionSearch()
 {
     // Check that we have a valid set of search criteria
     $search_terms = array('hos_num' => null, 'nhs_num' => null, 'first_name' => null, 'last_name' => null);
     foreach ($search_terms as $search_term => $search_value) {
         if (isset($_GET[$search_term]) && ($search_value = trim($_GET[$search_term]))) {
             // Pad hos_num
             if ($search_term == 'hos_num') {
                 $search_value = sprintf('%07s', $search_value);
             }
             $search_terms[$search_term] = $search_value;
         }
     }
     // if we are on a dev environment, this allows more flexible search terms (i.e. just a first name or surname - useful for testing
     // the multiple search results view. If we are live, enforces controls over search terms.
     if (!YII_DEBUG && !$search_terms['hos_num'] && !$search_terms['nhs_num'] && !($search_terms['first_name'] && $search_terms['last_name'])) {
         Yii::app()->user->setFlash('warning.invalid-search', 'Please enter a valid search.');
         $this->redirect(Yii::app()->homeUrl);
     }
     $search_terms = CHtml::encodeArray($search_terms);
     switch (@$_GET['sort_by']) {
         case 0:
             $sort_by = 'hos_num*1';
             break;
         case 1:
             $sort_by = 'title';
             break;
         case 2:
             $sort_by = 'first_name';
             break;
         case 3:
             $sort_by = 'last_name';
             break;
         case 4:
             $sort_by = 'dob';
             break;
         case 5:
             $sort_by = 'gender';
             break;
         case 6:
             $sort_by = 'nhs_num*1';
             break;
         default:
             $sort_by = 'hos_num*1';
     }
     $sort_dir = @$_GET['sort_dir'] == 0 ? 'asc' : 'desc';
     $page_num = (int) @$_GET['page_num'];
     $page_size = 20;
     $model = new Patient();
     $model->hos_num = $search_terms['hos_num'];
     $model->nhs_num = $search_terms['nhs_num'];
     $dataProvider = $model->search(array('currentPage' => $page_num, 'pageSize' => $page_size, 'sortBy' => $sort_by, 'sortDir' => $sort_dir, 'first_name' => CHtml::decode($search_terms['first_name']), 'last_name' => CHtml::decode($search_terms['last_name'])));
     $nr = $model->search_nr(array('first_name' => CHtml::decode($search_terms['first_name']), 'last_name' => CHtml::decode($search_terms['last_name'])));
     if ($nr == 0) {
         Audit::add('search', 'search-results', implode(',', $search_terms) . " : No results");
         $message = 'Sorry, no results ';
         if ($search_terms['hos_num']) {
             $message .= 'for Hospital Number <strong>"' . $search_terms['hos_num'] . '"</strong>';
         } elseif ($search_terms['nhs_num']) {
             $message .= 'for NHS Number <strong>"' . $search_terms['nhs_num'] . '"</strong>';
         } elseif ($search_terms['first_name'] && $search_terms['last_name']) {
             $message .= 'for Patient Name <strong>"' . $search_terms['first_name'] . ' ' . $search_terms['last_name'] . '"</strong>';
         } else {
             $message .= 'found for your search.';
         }
         Yii::app()->user->setFlash('warning.no-results', $message);
         $this->redirect(Yii::app()->homeUrl);
     } elseif ($nr == 1) {
         foreach ($dataProvider->getData() as $item) {
             $this->redirect(array('patient/view/' . $item->id));
         }
     } else {
         $this->renderPatientPanel = false;
         $pages = ceil($nr / $page_size);
         $this->render('results', array('data_provider' => $dataProvider, 'pages' => $pages, 'page_num' => $page_num, 'items_per_page' => $page_size, 'total_items' => $nr, 'search_terms' => $search_terms, 'sort_by' => (int) @$_GET['sort_by'], 'sort_dir' => (int) @$_GET['sort_dir']));
     }
 }
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'template-row-form', 'enableAjaxValidation' => false));
$accountsModel = Account::model()->findAll(array('join' => ' LEFT JOIN TemplateRowAccount ON t.id=TemplateRowAccount.accountId', 'select' => 't.id as code, TemplateRowAccount.id as id, CAST(CONCAT(t.code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 't.code', 'condition' => 'templateRowId=' . $model->id));
$allAccountsModel = Account::model()->findAll(array('select' => 'id, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code', 'condition' => 'companyId=' . $companyId));
//get rid of already selected accounts in the from list
$allAccountsModelCopy = $allAccountsModel;
foreach ($accountsModel as $key => $value) {
    foreach ($allAccountsModelCopy as $n => $allAccount) {
        if ($allAccount->id == $value->code) {
            unset($allAccountsModel[$n]);
            break;
        }
    }
}
$allAccounts = CHtml::encodeArray(CHtml::listData($allAccountsModel, 'id', 'name'));
$accounts = CHtml::encodeArray(CHtml::listData($accountsModel, 'id', 'name'));
?>
	<table class="dataGrid" style='margin:20px 20px 20px 20px;'><tr class='even'><td>
		<?php 
echo CHtml::listBox('accountsfrom', "", $allAccounts, array('style' => 'height:300px;', 'multiple' => 'true'));
?>
	</td><td>
		<table><tr><td>
		<?php 
echo CHtml::submitButton('=>', array('name' => 'Add', 'title' => Yii::t('lazy8', 'contexthelp.Accounts.Add Row')));
?>
		</td></tr><tr><td>
		<?php 
echo CHtml::submitButton('<=', array('name' => 'Remove', 'title' => Yii::t('lazy8', 'contexthelp.Accounts.Remove Row')));
?>
		</td></tr></table>
Exemplo n.º 19
0
 /**
  * @dataProvider providerEncodeArray
  *
  * @param type $data
  * @param type $assertion
  */
 public function testEncodeArray($data, $assertion)
 {
     $this->assertEquals($assertion, CHtml::encodeArray($data));
 }
Exemplo n.º 20
0
<?php 
echo CHtml::beginForm();
?>

<?php 
echo CHtml::errorSummary($models);
?>
<p>
<div class="simple">
<?php 
echo CHtml::label(Yii::t('lazy8', 'Language code'), false, array('class' => 'help', 'title' => Yii::t('lazy8', 'contexthelp.Language code'), 'onclick' => 'alert(this.title)'));
//this eval creats the $list array for the list box.
$phpcode = User::optionsUserTemplate();
eval($phpcode['languagecode'][4]);
echo CHtml::dropDownList('langcode', $language, CHtml::encodeArray($list), array('onchange' => "this.form.submit()"));
echo CHtml::encode("Version=" . $version);
?>
</div>
</p>


<table class="dataGrid">
  <thead>
  <tr>
    <th><?php 
echo $sort->link('category');
?>
</th>
    <th><?php 
echo $sort->link('messagekey');
Exemplo n.º 21
0
<p>
<?php 
echo Yii::t('lazy8', 'Fields with a red star are required') . ' <span class="required">*</span>';
?>
</p>

<?php 
echo CHtml::beginForm();
?>

<?php 
echo CHtml::errorSummary($model);
$cLoc = null;
$dateformatter = null;
$companies = CHtml::encodeArray(CHtml::listData(Company::model()->findAll(array('select' => 'id, CAST(CONCAT(code,\' \',name) AS CHAR CHARACTER SET utf8) as name', 'order' => 'code')), 'id', 'name'));
$companies[0] = Yii::t('lazy8', '-- ' . 'all' . ' --');
?>
<div class="simple">
<?php 
echo CHtml::activeLabelEx($model, 'companyId', array('class' => 'help', 'title' => Yii::t('lazy8', 'contexthelp.companyId'), 'onclick' => 'alert(this.title)'));
echo CHtml::activeDropDownList($model, "companyId", $companies);
?>
</div>
<div class="simple">
<?php 
echo CHtml::activeLabelEx($model, 'name', array('class' => 'help', 'title' => Yii::t('lazy8', 'contexthelp.name'), 'onclick' => 'alert(this.title)'));
echo CHtml::activeTextField($model, 'name', array('size' => 35, 'maxlength' => 100));
?>
</div>
<div class="simple">
 /**
  * Validates the attributes of the object.
  * Since $enableCombinedValidation is set to true, all attributes will be passed on together in array $attributes
  * If there is any error, the error message is added to the object.
  * @param CModel $object the object being validated
  * @param array $attributes the attribute(s) being validated
  * @throws CException if given table does not have specified column name
  */
 protected function validateAttribute($object, $attributes)
 {
     if (is_string($attributes)) {
         $attributes = preg_split('/[\\s,]+/', $attributes, -1, PREG_SPLIT_NO_EMPTY);
     }
     if ($this->attributeNames !== null && is_string($this->attributeNames)) {
         $this->attributeNames = preg_split('/[\\s,]+/', $this->attributeNames, -1, PREG_SPLIT_NO_EMPTY);
     }
     $className = $this->className === null ? get_class($object) : Yii::import($this->className);
     $finder = $this->getModel($className);
     $table = $finder->getTableSchema();
     $attributeNames = $this->attributeNames === null ? $attributes : $this->attributeNames;
     if (!is_array($attributeNames)) {
         throw new CException(t('"{attributeNames}" is not an array.', array('{attributeNames}' => $attributeNames)));
     }
     foreach ($attributeNames as $attribute) {
         if (($columns[$attribute] = $table->getColumn($attribute)) === null) {
             throw new CException(Yii::t('yii', 'Table "{table}" does not have a column named "{column}".', array('{column}' => $attribute, '{table}' => $table->name)));
         }
     }
     $allEmpty = true;
     foreach ($attributeNames as $attribute) {
         $columnNames[$attribute] = $columns[$attribute]->rawName;
         $values[$attribute] = $object->{$attribute};
         if (!empty($values[$attribute])) {
             $allEmpty = false;
         }
         if (is_array($values[$attribute])) {
             // https://github.com/yiisoft/yii/issues/1955
             $this->addError($object, $attribute, Yii::t('yii', '{attribute} is invalid.'));
             return;
         }
     }
     if ($this->allowEmpty && $allEmpty) {
         return;
     }
     $criteria = new CDbCriteria();
     if ($this->criteria !== array()) {
         $criteria->mergeWith($this->criteria);
     }
     $tableAlias = empty($criteria->alias) ? $finder->getTableAlias(true) : $criteria->alias;
     foreach ($attributeNames as $attribute) {
         $attributeLabels[$attribute] = $object->getAttributeLabel($attribute);
         $value = $values[$attribute];
         $columnName = $columnNames[$attribute];
         $valueParamName = CDbCriteria::PARAM_PREFIX . CDbCriteria::$paramCount++;
         // something like :ycp5 ==> parameter to be replaced by value
         $criteria->addCondition($this->caseSensitive ? "{$tableAlias}.{$columnName}={$valueParamName}" : "LOWER({$tableAlias}.{$columnName})=LOWER({$valueParamName})");
         $criteria->params[$valueParamName] = $value;
     }
     if (!$object instanceof CActiveRecord || $object->isNewRecord || $object->tableName() !== $finder->tableName()) {
         $exists = $finder->exists($criteria);
     } else {
         $criteria->limit = 2;
         $objects = $finder->findAll($criteria);
         $n = count($objects);
         if ($n === 1) {
             // $columns contains the column for each given attribute in attribute=>column pairs.
             // check if those columns constitute a composite primary key.
             $pk_new = $object->getPrimaryKey();
             if (is_array($pk_new)) {
                 $pk_cols = sort(array_keys($pk_new));
                 $given_cols = sort(array_values($columns));
                 if ($given_cols == $pk_cols) {
                     // primary key is modified and not unique
                     $exists = $object->getOldPrimaryKey() != $object->getPrimaryKey();
                 } else {
                     // non-primary key, need to exclude the current record based on PK
                     $exists = array_shift($objects)->getPrimaryKey() != $object->getOldPrimaryKey();
                 }
             } else {
                 // non-primary key, need to exclude the current record based on PK
                 $exists = array_shift($objects)->getPrimaryKey() != $object->getOldPrimaryKey();
             }
         } else {
             $exists = $n > 1;
         }
     }
     if ($exists) {
         $att = join(',', $attributeLabels);
         $val = join(',', CHtml::encodeArray($values));
         $parameters = array('{attributes}' => $att, '{values}' => $val);
         foreach ($values as $a => $v) {
             $parameters['{value_' . $a . '}'] = $v;
         }
         foreach ($attributeLabels as $a => $v) {
             $parameters['{attr_' . $a . '}'] = $v;
         }
         $msg = Yii::t('ECompositeUniqueValidator', '{attributes} with "{values}" already exists.');
         $message = $this->message !== null ? $this->message : $msg;
         if ($this->attributesToAddError === null) {
             $this->addError($object, $attributeNames[0], $message, $parameters);
         } else {
             $as = explode(',', $this->attributesToAddError);
             foreach ($as as $ae) {
                 $this->addError($object, $ae, $message, $parameters);
             }
         }
     }
 }