コード例 #1
0
 public function loadModel($id)
 {
     $m = TcmnCommunication::model();
     // apply scope, if available
     $scopes = $m->scopes();
     if (isset($scopes[$this->scope])) {
         $m->{$this->scope}();
     }
     $model = $m->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('D2tasksModule.crud', 'The requested page does not exist.'));
     }
     return $model;
 }
コード例 #2
0
ファイル: _tcmn_grid.php プロジェクト: dbrisinajumi/d2tasks
<?php

$can_edit = (bool) Yii::app()->user->checkAccess("D2tasks.TcmnCommunication.Update");
$bft = !$can_edit ? 'false' : 'true';
$tcmn_model = new TcmnCommunication();
$tcmn_model->tcmn_ttsk_id = $model->primaryKey;
// render grid view
$this->widget('TbGridView', array('id' => 'tcmn-communication-grid', 'dataProvider' => $tcmn_model->search(), 'template' => '{summary}{items}', 'rowCssClassExpression' => '$data->tcmnTcst->tcst_css_class', 'summaryText' => '&nbsp;', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'tcmn_pprs_id', 'value' => !$can_edit ? '!empty($data->tcmn_pprs_id)?$data->tcmnPprs->itemLabel:" - "' : '', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2tasks/tcmnCommunication/editableSaver'), 'source' => CHtml::listData(PprsPerson::model()->getSysCompanyPersons(), 'pprs_id', 'itemLabel'), 'placement' => 'right', 'apply' => $can_edit)), array('class' => 'editable.EditableColumn', 'name' => 'tcmn_client_pprs_id', 'value' => !$can_edit ? '!empty($data->tcmn_client_pprs_id)?$data->tcmnClientPprs->itemLabel:" - "' : '', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2tasks/tcmnCommunication/editableSaver'), 'source' => CHtml::listData(PprsPerson::model()->getCompanyPersons($model->ttsk_ccmp_id), 'pprs_id', 'itemLabel'), 'apply' => $can_edit)), array('class' => 'editable.EditableColumn', 'name' => 'tcmn_task', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//d2tasks/tcmnCommunication/editableSaver'), 'apply' => $can_edit)), array('class' => 'editable.EditableColumn', 'name' => 'tcmn_result', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//d2tasks/tcmnCommunication/editableSaver'), 'apply' => $can_edit)), array('class' => 'editable.EditableColumn', 'name' => 'tcmn_tcst_id', 'value' => '!empty($data->tcmn_tcst_id)?$data->tcmnTcst->itemLabel:" - "', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2tasks/tcmnCommunication/editableSaver'), 'source' => CHtml::listData(TcstCommunicationStatus::model()->findAll(), 'tcst_id', 'itemLabel'), 'apply' => $can_edit)), array('class' => 'editable.EditableColumn', 'name' => 'tcmn_datetime', 'editable' => array('type' => 'datetime', 'url' => $this->createUrl('//d2tasks/tcmnCommunication/editableSaver'), 'apply' => $can_edit)), array('class' => 'editable.EditableColumn', 'name' => 'tcmn_tmed_id', 'value' => '!empty($data->tcmn_tmed_id)?$data->tcmnTmed->itemLabel:" - "', 'type' => 'raw', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//d2tasks/tcmnCommunication/editableSaver'), 'source' => CHtml::listData(TmedMedia::model()->findAll(array('limit' => 1000)), 'tmed_id', 'itemLabel'), 'apply' => $can_edit)))));
コード例 #3
0
ファイル: D2files.php プロジェクト: dbrisinajumi/d2files
 /**
  * create project 
  * @param array $settings 
  * @return boolean
  */
 public function createProject($settings)
 {
     //currently only for persons create project
     if ($this->model != 'd2person.PprsPerson') {
         return false;
     }
     //validate user roles with setting roles
     if (isset($settings['user_roles'])) {
         $user_roles = Authassignment::model()->getUserRoles(Yii::app()->user->id);
         $a = array_intersect($user_roles, $settings['user_roles']);
         if (empty($a)) {
             return false;
         }
     }
     $model = PprsPerson::model()->findByPk($this->model_id);
     //create project
     $ttsk = new TtskTask();
     $ttsk->ttsk_pprs_id = $this->model_id;
     $ttsk->ttsk_name = 'New attachment to ' . $model->itemLabel;
     $ttsk->ttsk_description = '';
     $ttsk->ttsk_tstt_id = $settings['new_project_status'];
     //not started
     try {
         if (!$ttsk->save()) {
             return false;
         }
     } catch (Exception $e) {
         return false;
     }
     //create task
     $tcmn = new TcmnCommunication();
     $tcmn->tcmn_ttsk_id = $ttsk->ttsk_id;
     $tcmn->tcmn_task = 'Validate attachment:' . PHP_EOL;
     $tcmn->tcmn_task .= $this->file_name . ' ' . $this->add_datetime;
     $tcmn->tcmn_tcst_id = $settings['task_init_status'];
     $tcmn->tcmn_datetime = new CDbExpression('ADDDATE(NOW(),' . $settings['task_due_in_days'] . ' )');
     try {
         if (!$tcmn->save()) {
             return false;
         }
     } catch (Exception $e) {
         return false;
     }
     return true;
 }