示例#1
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param mixed $id the ID of the model to be loaded
  * @param string $modelClass the model class name
  * @return GxActiveRecord the loaded model
  */
 public function loadModel($id, $modelClass)
 {
     $model = GxActiveRecord::model($modelClass)->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.'));
     }
     return $model;
 }
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->creado = new CDbExpression('NOW()');
     }
     $this->modificado = new CDbExpression('NOW()');
     return parent::beforeSave();
 }
 public function getDbConnection()
 {
     if ($this->shardUserId) {
         self::$db = DbManager::getUserShard($this->shardUserId, $this->dbComponentId);
     } elseif ($this->dbComponentId) {
         self::$db = DbManager::getDb($this->dbComponentId);
     }
     return parent::getDbConnection();
 }
示例#4
0
 public function loadModel($key, $modelClass)
 {
     if (is_array($key)) {
         return parent::loadModel($key, $modelClass);
     }
     $staticModel = GxActiveRecord::model($modelClass);
     $model = $staticModel->findByPk($key);
     if (!$model) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#5
0
	/**
	 * Returns all the relations of the specified model.
	 * @param string $modelClass The model class name.
	 * @return array The relations. Each array item is
	 * a relation as an array, having 3 items:
	 * 0: the relation name,
	 * 1: the relation type,
	 * 2: the foreign key,
	 * 3: the related active record class name.
	 * Or an empty array if no relations were found.
	 */
	public function getRelations($modelClass) {
		$relations = GxActiveRecord::model($modelClass)->relations();
		$result = array();
		foreach ($relations as $relationName => $relation) {
			$result[] = array(
				$relationName, // the relation name
				$relation[0], // the relation type
				$relation[2], // the foreign key
				$relation[1] // the related active record class name
			);
		}
		return $result;
	}
示例#6
0
文件: view.php 项目: rapbore/rch2
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' ' . $model->label(), 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Delete') . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo Yii::t('app', 'View') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'cupo', 'type' => 'raw', 'value' => $model->cupo !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->cupo)), array('cupo/view', 'id' => GxActiveRecord::extractPkValue($model->cupo, true))) : null), array('name' => 'user', 'type' => 'raw', 'value' => $model->user !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->user)), array('user/view', 'id' => GxActiveRecord::extractPkValue($model->user, true))) : null), array('name' => 'recarga', 'type' => 'raw', 'value' => $model->recarga !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->recarga)), array('recarga/view', 'id' => GxActiveRecord::extractPkValue($model->recarga, true))) : null), 'fecha', 'comentario', 'estado')));
示例#7
0
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model) => array('view', 'id' => GxActiveRecord::extractPkValue($model, true)), Yii::t('app', 'Update'));
$this->menu = array(array('label' => Yii::t('app', 'Manage') . ' ' . IguCompanytype::label(2), 'url' => array('admin')));
$this->beginWidget('zii.widgets.CPortlet', array('htmlOptions' => array('class' => '')));
$this->widget('bootstrap.widgets.TbMenu', array('type' => 'pills', 'items' => array(array('label' => 'Create', 'icon' => 'icon-plus', 'url' => Yii::app()->controller->createUrl('create'), 'linkOptions' => array()), array('label' => 'List', 'icon' => 'icon-th-list', 'url' => Yii::app()->controller->createUrl('index'), 'linkOptions' => array()), array('label' => 'Manage', 'icon' => 'icon-search', 'url' => Yii::app()->controller->createUrl('admin'), 'linkOptions' => array('class' => 'search-button')), array('label' => 'Export to PDF', 'icon' => 'icon-download', 'url' => Yii::app()->controller->createUrl('GeneratePdf'), 'linkOptions' => array('target' => '_blank'), 'visible' => true), array('label' => 'Export to Excel', 'icon' => 'icon-download', 'url' => Yii::app()->controller->createUrl('GenerateExcel'), 'linkOptions' => array('target' => '_blank'), 'visible' => true))));
$this->endWidget();
?>

<h3><?php 
echo Yii::t('app', 'Update') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h3>

<?php 
$this->renderPartial('_form', array('model' => $model));
示例#8
0
文件: view.php 项目: cntabana/inyungu
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' ' . $model->label(), 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Delete') . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo Yii::t('app', 'View') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'idclient0', 'type' => 'raw', 'value' => $model->idclient0 !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->idclient0)), array('iguRegistration/view', 'id' => GxActiveRecord::extractPkValue($model->idclient0, true))) : null), 'idproduct', 'cashinvested', 'cashprofit', 'year')));
?>

示例#9
0
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'Listar') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Crear') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Actualizar') . ' ' . $model->label(), 'url' => array('update', 'id' => $model->iddocumentoexistente)), array('label' => Yii::t('app', 'Eliminar') . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->iddocumentoexistente), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('app', 'Administrar') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo Yii::t('app', 'Ver') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('iddocumentoexistente', array('name' => 'documentoanexo', 'type' => 'raw', 'value' => $model->documentoanexo !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->documentoanexo)), array('documentoAnexo/view', 'id' => GxActiveRecord::extractPkValue($model->documentoanexo, true))) : null), 'archivo', 'matricula_id', 'docente_id', 'fecha_creacion', 'usuario_id')));
?>

示例#10
0
文件: view.php 项目: dev-lav/htdocs
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'Listar') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Agregar') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Editar') . ' ' . $model->label(), 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Borrar') . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('app', 'Administrar') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('nombre', array('name' => 'idAreaEmpresa', 'type' => 'raw', 'value' => $model->idAreaEmpresa !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->idAreaEmpresa)), array('areasEmpresa/view', 'id' => GxActiveRecord::extractPkValue($model->idAreaEmpresa, true))) : null))));
 protected function dataTables($aColumns, $modelClass, $customQuery = NULL)
 {
     $staticModel = GxActiveRecord::model($modelClass);
     $sIndexColumn = $staticModel->getTableSchema()->primaryKey;
     $namaTabel = $staticModel->tableName();
     /*
      * Paging
      */
     $sLimit = "";
     if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') {
         $sLimit = "LIMIT " . $_GET['iDisplayStart'] . ", " . $_GET['iDisplayLength'];
     }
     /*
      * Ordering
      */
     $sOrder = "";
     if (isset($_GET['iSortCol_0'])) {
         $sOrder = "ORDER BY  ";
         for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) {
             if ($_GET['bSortable_' . intval($_GET['iSortCol_' . $i])] == "true") {
                 $sOrder .= "`" . $aColumns[intval($_GET['iSortCol_' . $i])] . "` " . $_GET['sSortDir_' . $i] . ", ";
             }
         }
         $sOrder = substr_replace($sOrder, "", -2);
         if ($sOrder == "ORDER BY") {
             $sOrder = "";
         }
     }
     /*
      * Filtering
      * NOTE this does not match the built-in DataTables filtering which does it
      * word by word on any field. It's possible to do here, but concerned about efficiency
      * on very large tables, and MySQL's regex functionality is very limited
      */
     $sWhere = "";
     if (isset($_GET['sSearch']) && $_GET['sSearch'] != "") {
         $sWhere = "WHERE (";
         for ($i = 0; $i < count($aColumns); $i++) {
             $sWhere .= "`" . $aColumns[$i] . "` LIKE '%" . $_GET['sSearch'] . "%' OR ";
         }
         $sWhere = substr_replace($sWhere, "", -3);
         $sWhere .= ')';
     }
     /* Individual column filtering */
     for ($i = 0; $i < count($aColumns); $i++) {
         if (isset($_GET['bSearchable_' . $i]) && $_GET['bSearchable_' . $i] == "true" && $_GET['sSearch_' . $i] != '') {
             if ($sWhere == "") {
                 $sWhere = "WHERE ";
             } else {
                 $sWhere .= " AND ";
             }
             $sWhere .= "`" . $aColumns[$i] . "` LIKE '%" . $_GET['sSearch_' . $i] . "%' ";
         }
     }
     if ($customQuery != NULL) {
         if (strlen(trim($sWhere)) == 0) {
             $sWhere = "WHERE " . $customQuery;
         } else {
             $sWhere .= " AND " . $customQuery;
         }
     }
     /*
      * SQL queries
      * Get data to display
      */
     $sQuery = "\n\t\t   SELECT `" . str_replace(" , ", " ", implode("`, `", $aColumns)) . "`\n\t\t   FROM   {$namaTabel}\n\t\t   {$sWhere}\n\t\t   {$sOrder}\n\t\t   {$sLimit}\n\t\t   ";
     //echo $sQuery;
     $rResult = Yii::app()->db->createCommand($sQuery)->queryAll();
     /* Data set length after filtering */
     $sQuery = "SELECT COUNT(*) AS FR\n\t\t   FROM   {$namaTabel}\n\t\t   {$sWhere}\n\t\t   {$sOrder}";
     $rResultFilterTotal = Yii::app()->db->createCommand($sQuery)->queryAll();
     foreach ($rResultFilterTotal as $v) {
         $aResultFilterTotal = $v;
     }
     $iFilteredTotal = $aResultFilterTotal["FR"];
     /* Total data set length */
     $sQuery = "\n\t\t   SELECT COUNT(`" . $sIndexColumn . "`) as total\n\t\t   FROM   {$namaTabel}";
     if ($customQuery != NULL) {
         $sQuery .= " WHERE " . $customQuery;
     }
     $rResultTotal = Yii::app()->db->createCommand($sQuery)->queryAll();
     $i = 0;
     $iTotal = 0;
     foreach ($rResultTotal as $v) {
         $iTotal = $v["total"];
     }
     return array("result" => $rResult, "total" => $iTotal, "filtertotal" => $iFilteredTotal);
 }
示例#12
0
<?php

/* @var $this TexteController */
/* @var $model Texte */
$this->breadcrumbs = array(Yii::t('app', 'Administration') => $this->createUrl('/admin/index'), $model->label(2) => array('index'), Yii::t('app', 'Update'));
$this->menu = array(array('label' => $model->label() . ' ' . Yii::t('app', 'Create'), 'url' => array('create'), "icon" => "plus-sign"), array('label' => $model->label() . ' ' . Yii::t('app', 'View'), 'url' => array('view', 'id' => GxActiveRecord::extractPkValue($model, true)), "icon" => "eye-open"), array('label' => $model->label() . ' ' . Yii::t('app', 'Delete'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?'), "icon" => "remove"));
?>

	<h1><?php 
echo Yii::t('app', 'Update') . ': ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->renderPartial('_form', array('model' => $model));
示例#13
0
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' ' . $model->label(), 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Delete') . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo Yii::t('app', 'View') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'test', 'type' => 'raw', 'value' => $model->test !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->test)), array('test/view', 'id' => GxActiveRecord::extractPkValue($model->test, true))) : null), 'name')));
?>

示例#14
0
文件: view.php 项目: rapbore/rch2
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' ' . $model->label(), 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Delete') . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array(array('name' => 'local', 'type' => 'raw', 'value' => $model->local !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->local)), array('local/view', 'id' => GxActiveRecord::extractPkValue($model->local, true))) : null), 'celular', 'compania', 'monto', 'estado')));
?>

示例#15
0
文件: view.php 项目: hanihh/vvs_v2
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' ' . $model->label(), 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Delete') . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo Yii::t('app', 'View') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'subdistribution', 'type' => 'raw', 'value' => $model->subdistribution !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->subdistribution)), array('subdistribution/view', 'id' => GxActiveRecord::extractPkValue($model->subdistribution, true))) : null), array('name' => 'vendor', 'type' => 'raw', 'value' => $model->vendor !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->vendor)), array('vendor/view', 'id' => GxActiveRecord::extractPkValue($model->vendor, true))) : null), array('name' => 'phone', 'type' => 'raw', 'value' => $model->phone !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->phone)), array('phone/view', 'id' => GxActiveRecord::extractPkValue($model->phone, true))) : null))));
?>

示例#16
0
<?php

$this->breadcrumbs = array('Pah Anggarans' => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' PahAnggaran', 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' PahAnggaran', 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' PahAnggaran', 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Delete') . ' PahAnggaran', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')));
?>

<h1><?php 
echo Yii::t('app', 'View');
?>
 PahAnggaran #<?php 
echo GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'doc_ref', 'periode_bulan', 'periode_tahun', 'trans_date', 'lock', array('label' => 'Users', 'type' => 'raw', 'value' => GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->users)), array('users/view', 'id' => GxActiveRecord::extractPkValue($model->users, true))))), 'itemTemplate' => "<tr class=\"{class}\"><td style=\"width: 120px\"><b>{label}</b></td><td>{value}</td></tr>\n", 'htmlOptions' => array('class' => 'table')));
?>

<!--h2>Pah Anggaran Detils</h2-->
<?php 
/*
	echo GxHtml::openTag('ul');
	foreach($model->pahAnggaranDetils as $relatedModel) {
		echo GxHtml::openTag('li');
		echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('pahAnggaranDetil/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
		echo GxHtml::closeTag('li');
	}
	echo GxHtml::closeTag('ul');*/
示例#17
0
<?php

$this->breadcrumbs = array('Pe Donaturs' => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' PeDonatur', 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' PeDonatur', 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' PeDonatur', 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Delete') . ' PeDonatur', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')));
?>

<h1><?php 
echo Yii::t('app', 'View');
?>
 PeDonatur #<?php 
echo GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'name', 'phone', 'alamat', 'inactive', array('label' => 'PeChartMaster', 'type' => 'raw', 'value' => GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->accountCode)), array('peChartMaster/view', 'id' => GxActiveRecord::extractPkValue($model->accountCode, true))))), 'itemTemplate' => "<tr class=\"{class}\"><td style=\"width: 120px\"><b>{label}</b></td><td>{value}</td></tr>\n", 'htmlOptions' => array('class' => 'table')));
?>

<!--h2>Pe Kas Masuks</h2-->
<?php 
/*
	echo GxHtml::openTag('ul');
	foreach($model->peKasMasuks as $relatedModel) {
		echo GxHtml::openTag('li');
		echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('peKasMasuk/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
		echo GxHtml::closeTag('li');
	}
	echo GxHtml::closeTag('ul');*/
示例#18
0
 /**
  * Saves the MANY_MANY relations of this record.
  * Internally used by {@link saveWithRelated} and {@link saveMultiple}.
  * See {@link saveWithRelated} and {@link saveMultiple} for details.
  * @param array $relatedData The relation data in the format returned by {@link GxController::getRelatedData}.
  * @param boolean $runValidation Whether to perform validation before saving the record.
  * @param boolean $batch Whether to try to do the deletes and inserts in batch.
  * While batches may be faster, using active record instances provides better control, validation, event support etc.
  * Batch is only supported for deletes.
  * @return boolean Whether the saving succeeds.
  * @see saveWithRelated
  * @see saveMultiple
  * @throws CException If this record is new.
  * @throws CException If this active record has composite PK.
  * @uses pivotModels
  */
 protected function saveRelated($relatedData, $runValidation = true, $batch = true)
 {
     if (empty($relatedData)) {
         return true;
     }
     // This active record can't be new for the method to work correctly.
     if ($this->getIsNewRecord()) {
         throw new CException(Yii::t('giix.messages', 'Cannot save the related records to the database because the main record is new.'));
     }
     // Save each related data.
     foreach ($relatedData as $relationName => $relationData) {
         // The pivot model class name.
         $pivotClassNames = $this->pivotModels();
         $pivotClassName = $pivotClassNames[$relationName];
         $pivotModelStatic = GxActiveRecord::model($pivotClassName);
         // Get the foreign key names for the models.
         $activeRelation = $this->getActiveRelation($relationName);
         $relatedClassName = $activeRelation->className;
         if (preg_match('/(.+)\\((.+),\\s*(.+)\\)/', $activeRelation->foreignKey, $matches)) {
             // By convention, the first fk is for this model, the second is for the related model.
             $thisFkName = $matches[2];
             $relatedFkName = $matches[3];
         }
         // Get the primary key value of the main model.
         $thisPkValue = $this->getPrimaryKey();
         if (is_array($thisPkValue)) {
             throw new CException(Yii::t('giix.messages', 'Composite primary keys are not supported.'));
         }
         // Get the current related models of this relation and map the current related primary keys.
         $currentRelation = $pivotModelStatic->findAll(new CDbCriteria(array('select' => $relatedFkName, 'condition' => "{$thisFkName} = :thisfkvalue", 'params' => array(':thisfkvalue' => $thisPkValue))));
         $currentMap = array();
         foreach ($currentRelation as $currentRelModel) {
             $currentMap[] = $currentRelModel->{$relatedFkName};
         }
         // Compare the current map to the new data and identify what is to be kept, deleted or inserted.
         $newMap = $relationData;
         $deleteMap = array();
         $insertMap = array();
         if ($newMap !== null) {
             // Identify the relations to be deleted.
             foreach ($currentMap as $currentItem) {
                 if (!in_array($currentItem, $newMap)) {
                     $deleteMap[] = $currentItem;
                 }
             }
             // Identify the relations to be inserted.
             foreach ($newMap as $newItem) {
                 if (!in_array($newItem, $currentMap)) {
                     $insertMap[] = $newItem;
                 }
             }
         } else {
             // If the new data is empty, everything must be deleted.
             $deleteMap = $currentMap;
         }
         // If nothing changed, we simply continue the loop.
         if (empty($deleteMap) && empty($insertMap)) {
             continue;
         }
         // Now act inserting and deleting the related data: first prepare the data.
         // Inject the foreign key names of both models and the primary key value of the main model in the maps.
         foreach ($deleteMap as &$deleteMapPkValue) {
             $deleteMapPkValue = array_merge(array($relatedFkName => $deleteMapPkValue), array($thisFkName => $thisPkValue));
         }
         unset($deleteMapPkValue);
         // Clear reference;
         foreach ($insertMap as &$insertMapPkValue) {
             $insertMapPkValue = array_merge(array($relatedFkName => $insertMapPkValue), array($thisFkName => $thisPkValue));
         }
         unset($insertMapPkValue);
         // Clear reference;
         // Now act inserting and deleting the related data: then execute the changes.
         // Delete the data.
         if (!empty($deleteMap)) {
             if ($batch) {
                 // Delete in batch mode.
                 if ($pivotModelStatic->deleteByPk($deleteMap) !== count($deleteMap)) {
                     return false;
                 }
             } else {
                 // Delete one active record at a time.
                 foreach ($deleteMap as $value) {
                     $pivotModel = GxActiveRecord::model($pivotClassName)->findByPk($value);
                     if (!$pivotModel->delete()) {
                         return false;
                     }
                 }
             }
         }
         // Insert the new data.
         foreach ($insertMap as $value) {
             $pivotModel = new $pivotClassName();
             $pivotModel->setAttributes($value);
             if (!$pivotModel->save($runValidation)) {
                 return false;
             }
         }
     }
     // This is the end of the loop "save each related data".
     return true;
 }
示例#19
0
文件: view.php 项目: rapbore/rch2
<?php 
echo '<?php';
?>
 $this->widget('bootstrap.widgets.TbDetailView', array(
	'data' => $model,
	'attributes' => array(
<?php 
foreach ($this->tableSchema->columns as $column) {
    echo $this->generateDetailViewAttribute($this->modelClass, $column) . ",\n";
}
?>
	),
)); ?>

<?php 
foreach (GxActiveRecord::model($this->modelClass)->relations() as $relationName => $relation) {
    if ($relation[0] == GxActiveRecord::HAS_MANY || $relation[0] == GxActiveRecord::MANY_MANY) {
        ?>
<h2><?php 
        echo '<?php';
        ?>
 echo GxHtml::encode($model->getRelationLabel('<?php 
        echo $relationName;
        ?>
')); ?></h2>
<?php 
        echo "<?php\n";
        ?>
	echo GxHtml::openTag('ul');
	foreach($model-><?php 
        echo $relationName;
示例#20
0
 public function loadModel($key, $modelClass)
 {
     // Get the static model.
     $staticModel = GxActiveRecord::model($modelClass);
     if (is_array($key)) {
         // The key is an array.
         // Check if there are column names indexing the values in the array.
         reset($key);
         if (key($key) === 0) {
             // There are no attribute names.
             // Check if there are multiple PK values. If there's only one, start again using only the value.
             if (count($key) === 1) {
                 return $this->loadModel($key[0], $modelClass);
             }
             // Now we will use the composite PK.
             // Check if the table has composite PK.
             $tablePk = $staticModel->getTableSchema()->primaryKey;
             if (!is_array($tablePk)) {
                 throw new CHttpException(400, Yii::t('giix', 'Your request is invalid.'));
             }
             // Check if there are the correct number of keys.
             if (count($key) !== count($tablePk)) {
                 throw new CHttpException(400, Yii::t('giix', 'Your request is invalid.'));
             }
             // Get an array of PK values indexed by the column names.
             $pk = $staticModel->fillPkColumnNames($key);
             // Then load the model.
             $model = $staticModel->findByPk($pk);
         } else {
             // There are attribute names.
             // Then we load the model now.
             $model = $staticModel->findByAttributes($key);
         }
     } else {
         // The key is not an array.
         // Check if the table has composite PK.
         $tablePk = $staticModel->getTableSchema()->primaryKey;
         if (is_array($tablePk)) {
             // The table has a composite PK.
             // The key must be a string to have a PK separator.
             if (!is_string($key)) {
                 throw new CHttpException(400, Yii::t('giix', 'Your request is invalid.'));
             }
             // There must be a PK separator in the key.
             if (stripos($key, GxActiveRecord::$pkSeparator) === false) {
                 throw new CHttpException(400, Yii::t('giix', 'Your request is invalid.'));
             }
             // Generate an array, splitting by the separator.
             $keyValues = explode(GxActiveRecord::$pkSeparator, $key);
             // Start again using the array.
             return $this->loadModel($keyValues, $modelClass);
         } else {
             // The table has a single PK.
             // Then we load the model now.
             $model = $staticModel->findByPk($key);
         }
     }
     // Check if we have a model.
     if ($model === null) {
         throw new CHttpException(404, Yii::t('giix', 'The requested page does not exist.'));
     }
     return $model;
 }
示例#21
0
<?php

$this->breadcrumbs = array('Pe Kas Keluars' => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' PeKasKeluar', 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' PeKasKeluar', 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' PeKasKeluar', 'url' => array('update', 'id' => $model->kas_keluar_id)), array('label' => Yii::t('app', 'Delete') . ' PeKasKeluar', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->kas_keluar_id), 'confirm' => 'Are you sure you want to delete this item?')));
?>

<h1><?php 
echo Yii::t('app', 'View');
?>
 PeKasKeluar #<?php 
echo GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('kas_keluar_id', 'doc_ref', 'no_bukti', 'amount', 'entry_time', 'trans_date', 'trans_via', array('label' => 'PeSuppliers', 'type' => 'raw', 'value' => GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->peSupplier)), array('peSuppliers/view', 'id' => GxActiveRecord::extractPkValue($model->peSupplier, true)))), array('label' => 'PeChartMaster', 'type' => 'raw', 'value' => GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->peAccountCode)), array('peChartMaster/view', 'id' => GxActiveRecord::extractPkValue($model->peAccountCode, true)))), array('label' => 'PeBankAccounts', 'type' => 'raw', 'value' => GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->peBankAccounts)), array('peBankAccounts/view', 'id' => GxActiveRecord::extractPkValue($model->peBankAccounts, true)))), array('label' => 'Users', 'type' => 'raw', 'value' => GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->users)), array('users/view', 'id' => GxActiveRecord::extractPkValue($model->users, true))))), 'itemTemplate' => "<tr class=\"{class}\"><td style=\"width: 120px\"><b>{label}</b></td><td>{value}</td></tr>\n", 'htmlOptions' => array('class' => 'table')));
?>

示例#22
0
<?php

$this->breadcrumbs = array('Pah Sub Aktivitases' => array('index'), GxHtml::valueEx($model) => array('view', 'id' => GxActiveRecord::extractPkValue($model, true)), Yii::t('app', 'Update'));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' PahSubAktivitas', 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' PahSubAktivitas', 'url' => array('create')), array('label' => Yii::t('app', 'View') . ' PahSubAktivitas', 'url' => array('view', 'id' => GxActiveRecord::extractPkValue($model, true))));
?>

<h1><?php 
echo Yii::t('app', 'Update');
?>
 PahSubAktivitas #<?php 
echo GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->renderPartial('_form', array('model' => $model));
示例#23
0
 /**
  * Generates the select data suitable for list-based HTML elements.
  * The select data has the attribute or related data as returned
  * by {@link CHtml::resolveValue}.
  * If the select data comes from a MANY_MANY or a HAS_MANY related
  * attribute (is a model or an array of models), it is transformed
  * to a string or an array of strings with the selected primary keys.
  * @param mixed $value The value of the attribute as returned by
  * {@link CHtml::resolveValue}.
  * @return mixed The select data.
  */
 public static function selectData($value)
 {
     // If $value is a model or an array of models, turn it into
     // a string or an array of strings with the pk values.
     if (is_object($value) && is_subclass_of($value, 'GxActiveRecord') || is_array($value) && !empty($value) && is_object($value[0]) && is_subclass_of($value[0], 'GxActiveRecord')) {
         return GxActiveRecord::extractPkValue($value, true);
     } else {
         return $value;
     }
 }
示例#24
0
 public function beforeSave()
 {
     $this->password = $this->hashPassword($this->password, $this->salt);
     return parent::beforeSave();
 }
示例#25
0
    echo GxHtml::openTag('li');
    echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('actor/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
    echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?>
<h2><?php 
echo GxHtml::encode($model->getRelationLabel('categories'));
?>
</h2>
<?php 
echo GxHtml::openTag('ul');
foreach ($model->categories as $relatedModel) {
    echo GxHtml::openTag('li');
    echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('category/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
    echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
?>
<h2><?php 
echo GxHtml::encode($model->getRelationLabel('inventories'));
?>
</h2>
<?php 
echo GxHtml::openTag('ul');
foreach ($model->inventories as $relatedModel) {
    echo GxHtml::openTag('li');
    echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('inventory/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
    echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
示例#26
0
文件: update.php 项目: dev-lav/htdocs
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model) => array('view', 'id' => GxActiveRecord::extractPkValue($model, true)), Yii::t('app', 'Editar'));
$this->menu = array(array('label' => Yii::t('app', 'Listar') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Agregar') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Ver') . ' ' . $model->label(), 'url' => array('view', 'id' => GxActiveRecord::extractPkValue($model, true))), array('label' => Yii::t('app', 'Administrar') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo Yii::t('app', 'Editar') . ' ' . GxHtml::encode($model->label()) . ' Patente N°: ' . '<font color="yellow">' . OrdenTrabajo::formatearPatente(GxHtml::encode(GxHtml::valueEx($model))) . '</font>';
?>
</h1>

<?php 
$this->renderPartial('_form', array('model' => $model));
示例#27
0
文件: view.php 项目: ngdvan/lntguitar
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' ' . $model->label(), 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Delete') . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo Yii::t('app', 'View') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'name', 'email', 'tel', 'birthday', array('name' => 'class', 'type' => 'raw', 'value' => $model->class !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->class)), array('classGuitar/view', 'id' => GxActiveRecord::extractPkValue($model->class, true))) : null), 'user_id', 'comment')));
?>

示例#28
0
文件: view.php 项目: hanihh/vvs_v2
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')), array('label' => Yii::t('app', 'Update') . ' ' . $model->label(), 'url' => array('update', 'id' => $model->id)), array('label' => Yii::t('app', 'Delete') . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo Yii::t('app', 'View') . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'name', 'description', 'create_date', 'valid', 'security_level', 'family:boolean', 'deleted_at')));
?>

<h2><?php 
echo GxHtml::encode($model->getRelationLabel('beneficiaryAttributes'));
?>
</h2>
<?php 
echo GxHtml::openTag('ul');
foreach ($model->beneficiaryAttributes as $relatedModel) {
    echo GxHtml::openTag('li');
    echo GxHtml::link(GxHtml::encode(GxHtml::valueEx($relatedModel)), array('beneficiaryAttribute/view', 'id' => GxActiveRecord::extractPkValue($relatedModel, true)));
    echo GxHtml::closeTag('li');
}
echo GxHtml::closeTag('ul');
示例#29
0
文件: BaseFiles.php 项目: ranvirp/rdp
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
示例#30
0
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), GxHtml::valueEx($model));
$this->menu = array(array('label' => 'List' . ' ' . $model->label(2), 'url' => array('index')), array('label' => 'Create' . ' ' . $model->label(), 'url' => array('create')), array('label' => 'Update' . ' ' . $model->label(), 'url' => array('update', 'id' => $model->payment_id)), array('label' => 'Delete' . ' ' . $model->label(), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->payment_id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => 'Manage' . ' ' . $model->label(2), 'url' => array('admin')));
?>

<h1><?php 
echo 'View' . ' ' . GxHtml::encode($model->label()) . ' ' . GxHtml::encode(GxHtml::valueEx($model));
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('payment_id', array('name' => 'customer', 'type' => 'raw', 'value' => $model->customer !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->customer)), array('customer/view', 'id' => GxActiveRecord::extractPkValue($model->customer, true))) : null), array('name' => 'staff', 'type' => 'raw', 'value' => $model->staff !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->staff)), array('staff/view', 'id' => GxActiveRecord::extractPkValue($model->staff, true))) : null), array('name' => 'rental', 'type' => 'raw', 'value' => $model->rental !== null ? GxHtml::link(GxHtml::encode(GxHtml::valueEx($model->rental)), array('rental/view', 'id' => GxActiveRecord::extractPkValue($model->rental, true))) : null), 'amount', 'payment_date', 'last_update')));
?>