本文整理汇总了PHP中Cases::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Cases::model方法的具体用法?PHP Cases::model怎么用?PHP Cases::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cases
的用法示例。
在下文中一共展示了Cases::model方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
// check if user has permissions to createSecuences
if (Yii::app()->user->checkAccess('createSecuences')) {
// create secuences object
$model = new Secuences();
// find case parent
$cases = Cases::model()->findByPk((int) $_GET['owner']);
// output message
$returnMessage = null;
// verify Secuences form exist
if (isset($_POST['Secuences'])) {
// set form elements to Secuences model attributes
$model->attributes = $_POST['Secuences'];
// validate and save
if ($model->save()) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'SecuenceCreated', 'log_resourceid' => $model->case_id, 'log_type' => Logs::LOG_CREATED, 'user_id' => Yii::app()->user->id, 'module_id' => 'cases', 'project_id' => $model->Cases->project_id);
Logs::model()->saveLog($attributes);
$returnMessage = Yii::t('secuences', 'successMessage');
// create new secuence model for clear inputs form
$model = new Secuences();
} else {
$returnMessage = Yii::t('secuences', 'errorMessage');
}
}
// output create page
$this->render('create', array('model' => $model, 'types' => SecuenceTypes::model()->findAll(), 'cases' => $cases, 'returnMessage' => $returnMessage));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例2: actionEditProcess
public function actionEditProcess()
{
try {
$post = StringHelper::filterArrayString($_POST);
$result = Cases::model()->edit($_POST);
if ($result == 1) {
Yii::app()->user->setFlash('success', 'Cập nhật dữ liệu thành công !');
$this->redirect(Yii::app()->createUrl('case/edit', array('id' => $post['id'])));
} else {
if ($result == 2) {
Yii::app()->user->setFlash('error', 'Cập nhật dữ liệu thất bại !');
$this->redirect(Yii::app()->createUrl('case/edit', array('id' => $post['id'])));
} else {
Yii::app()->user->setFlash('error', 'Không tồn tại tài liệu !');
$this->redirect(Yii::app()->createUrl('case/edit', array('id' => $post['id'])));
}
}
} catch (Exception $ex) {
var_dump($ex->getMessage());
}
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
if (Yii::app()->user->checkAccess('createValidations')) {
$model = new Validations();
$cases = Cases::model()->findByPk($_GET['owner']);
$returnMessage = null;
if (isset($_POST['Validations'])) {
$model->attributes = $_POST['Validations'];
if ($model->save()) {
// Guardar log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'ValidationCreated', 'log_resourceid' => $model->case_id, 'log_type' => Logs::LOG_CREATED, 'user_id' => Yii::app()->user->id, 'module_id' => 'cases', 'project_id' => $model->Cases->project_id);
Logs::model()->saveLog($attributes);
//$this->redirect(Yii::app()->createUrl('secuences/create', array('owner'=>$cases->case_id)));
$returnMessage = "Validation was succefully created.";
$model = new Validations();
}
}
$this->render('create', array('model' => $model, 'cases' => $cases, 'returnMessage' => $returnMessage));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例4: actionCreate
/**
* Creates a new model.
*/
public function actionCreate()
{
// create Comments Object
$model = new Comments();
// if Comments form exist
if (isset($_POST['Comments'])) {
// set form elements to Comments model attributes
$model->attributes = $_POST['Comments'];
$module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id)));
// set module_id finded to model
$model->module_id = $module->module_id;
$project = Yii::app()->user->getState('project_selected');
$model->project_id = $project;
// validate and save
if ($model->save()) {
// create an instance of file uploaded
$image = CUploadedFile::getInstancesByName('Comment');
// if file upload exist
if (count($image > 0)) {
// for each file uploaded
for ($i = 0; $i < count($image); $i++) {
// create an Document object
$modeldocs = new Documents();
$modeldocs->image = $image[$i];
if (!$modeldocs->image->getError()) {
// name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime())
$this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime());
// set the extension file uploaded
$extension = $modeldocs->image->getExtensionName();
// if no error saving file
if ($modeldocs->image->saveAs(self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) {
$modeldocs->project_id = $project;
$modeldocs->document_name = substr($modeldocs->image->getName(), 0, 30);
$modeldocs->document_description = $model->comment_text;
$modeldocs->document_path = self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension;
$modeldocs->document_revision = '1';
$modeldocs->document_uploadDate = date("Y-m-d");
$modeldocs->document_type = $modeldocs->image->getType();
$modeldocs->document_baseRevision = date('dmYHis');
$modeldocs->user_id = Yii::app()->user->id;
$modeldocs->comment_id = $model->primaryKey;
// save file uploaded as document
if ($modeldocs->save()) {
Yii::app()->user->setFlash('CommentMessageSuccess', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadOk'));
} else {
Yii::app()->user->setFlash('CommentMessage', $modeldocs->getErrors());
}
} else {
Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadError'));
}
} else {
Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->error . " " . Yii::t('comments', 'UploadCheckErrors'));
}
}
}
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CommentPosted', 'log_resourceid' => $model->comment_resourceid, 'log_type' => Logs::LOG_COMMENTED, 'log_commentid' => $model->primaryKey, 'user_id' => Yii::app()->user->id, 'module_id' => $module->module_name, 'project_id' => $project);
Logs::model()->saveLog($attributes);
// find project managers to sent comment via mail
$recipientsList = array();
$ProjectManagers = Projects::model()->findManagersByProject($project);
$managersArray = array();
foreach ($ProjectManagers as $manager) {
$managersArray['email'] = $manager->user_email;
$managersArray['name'] = $manager->CompleteName;
array_push($recipientsList, $managersArray);
}
// find task owners to send comment via mail
if ($module->module_name == 'tasks') {
$collaborators = Projects::model()->findAllUsersByProject($project);
$ColaboratorsArray = array();
foreach ($collaborators as $colaborator) {
$ColaboratorsArray['email'] = $colaborator->user_email;
$ColaboratorsArray['name'] = $colaborator->CompleteName;
// avoid to repeat email address
if (!in_array($ColaboratorsArray, $recipientsList)) {
array_push($recipientsList, $ColaboratorsArray);
}
}
}
// finding resource title
switch ($module->module_name) {
case "budgets":
$resourceModelTitle = Budgets::model()->findByPk($model->comment_resourceid)->budget_title;
break;
case "invoices":
$resourceModelTitle = Invoices::model()->findByPk($model->comment_resourceid)->invoice_number;
break;
case "expenses":
$resourceModelTitle = Expenses::model()->findByPk($model->comment_resourceid)->expense_name;
break;
case "documents":
$resourceModelTitle = Documents::model()->findByPk($model->comment_resourceid)->document_name;
break;
case "milestones":
$resourceModelTitle = Milestones::model()->findByPk($model->comment_resourceid)->milestone_title;
break;
//.........这里部分代码省略.........
示例5: actionPrintArea
public function actionPrintArea()
{
$documentary = Documentary::model()->searchByCondition($_GET, null, 2);
$wanted_abroad = WantedAbroad::model()->searchByCondition($_GET, null, 2);
$letters = Letters::model()->searchByCondition($_GET, null, 2);
$cases = Cases::model()->searchByCondition($_GET, null, 2);
$cases_abroad = CasesAbroadOther::model()->searchByCondition($_GET, null, 2);
$opinion = Opinion::model()->searchByCondition($_GET, null, 2);
$documentary_recieve = DocumentaryRecieve::model()->searchByCondition($_GET, null, 2);
$documentary_abroad = DocumentaryAbroad::model()->searchByCondition($_GET, null, 2);
$guide = Guide::model()->searchByCondition($_GET, null, 2);
$result = array('documentary' => $documentary, 'wanted_abroad' => $wanted_abroad, 'letters' => $letters, 'cases' => $cases, 'cases_abroad' => $cases_abroad, 'opinion' => $opinion, 'documentary_recieve' => $documentary_recieve, 'documentary_abroad' => $documentary_abroad, 'guide' => $guide);
$this->render('printArea', $result);
}
示例6: actionIndex
/**
* Lists all models.
*/
public function actionIndex()
{
if (Yii::app()->user->checkAccess('indexTasks')) {
$view = Yii::app()->user->getState('view') != null ? Yii::app()->user->getState('view') : 'list';
if (isset($_GET['view']) && !empty($_GET['view'])) {
if ($_GET['view'] == 'grid') {
$view = 'grid';
} elseif ($_GET['view'] == 'kanban') {
$view = 'kanban';
} else {
$view = 'list';
}
}
Yii::app()->user->setState('view', $view);
$model = new TasksSearchForm();
//$model->search();
//$model->unsetAttributes(); // clear any default values
$Milestones = Milestones::model()->with('Projects.Company.Cusers')->together()->findAll(array('condition' => 'Cusers.user_id = :user_id AND t.project_id = :project_id', 'params' => array(':user_id' => Yii::app()->user->id, ':project_id' => Yii::app()->user->getState('project_selected'))));
$Cases = Cases::model()->with('Projects.Company.Cusers')->together()->findAll(array('condition' => 'Cusers.user_id = :user_id AND t.project_id = :project_id', 'params' => array(':user_id' => Yii::app()->user->id, ':project_id' => Yii::app()->user->getState('project_selected'))));
if (isset($_GET['TasksSearchForm'])) {
$model->attributes = $_GET['TasksSearchForm'];
}
if ($view == 'kanban') {
$this->layout = 'column1';
}
$this->render('index', array('model' => $model, 'status' => Status::model()->findAllOrdered(), 'types' => TaskTypes::model()->findAll(), 'stages' => TaskStages::model()->findAll(), 'milestones' => $Milestones, 'cases' => $Cases, 'users' => Projects::model()->findAllUsersByProject(Yii::app()->user->getState('project_selected'))));
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例7: searchByCondition
public function searchByCondition($attr, $cnt = null, $pagination = 1)
{
$criteria = new CDbCriteria();
if (!empty($attr['date_start']) && !empty($attr['date_end'])) {
$date_start = strtotime($attr['date_start']);
$date_end = strtotime($attr['date_end']);
$criteria->addBetweenCondition('date_prosecution', $date_start, $date_end);
}
if (!empty($attr['obj_name'])) {
$obj_name = $attr['obj_name'];
$criteria->addSearchCondition('accused', $obj_name);
}
if (!empty($attr['assignee'])) {
$assignee = $attr['assignee'];
$criteria->addSearchCondition('investigator', $assignee);
}
if (!empty($attr['keyword'])) {
$keyword = $attr['keyword'];
$criteria->addSearchCondition('accused', $keyword, true, "OR", "LIKE");
$criteria->addSearchCondition('investigator', $keyword, true, "OR", "LIKE");
$criteria->addSearchCondition('detention_period', $keyword, true, "OR", "LIKE");
$criteria->addSearchCondition('investigation_period', $keyword, true, "OR", "LIKE");
$criteria->addSearchCondition('case_name', $keyword, true, "OR", "LIKE");
}
$count = Cases::model()->count($criteria);
if (!empty($cnt)) {
return $count;
}
if ($pagination != 1) {
$result = Cases::model()->findAll($criteria);
return $result;
}
$pages = new CPagination($count);
// results per page
$pages->pageSize = Yii::app()->params['limit'];
$pages->applyLimit($criteria);
$result = Cases::model()->findAll($criteria);
return array('models' => $result, 'pages' => $pages);
}
示例8: beforeAction
/**
* This method is invoked right before an action is to be executed (after all possible filters.)
* @param CAction $action the action to be executed.
* @return boolean whether the action should be executed
*/
public function beforeAction($action)
{
$response = false;
if (Yii::app()->user->getState('project_selected') != null) {
if (in_array($action->id, array('view', 'update'))) {
$response = Cases::model()->countCasesByProject((int) $_GET['id'], Yii::app()->user->getState('project_selected')) > 0 ? true : false;
} else {
$response = true;
}
} else {
$response = false;
}
if (!$response) {
throw new CHttpException(403, Yii::t('site', '403_Error'));
} else {
return $response;
}
}
示例9: countCasesByProject
public function countCasesByProject($case_id, $project_id)
{
return Cases::model()->count(array('condition' => 't.project_id = :project_id AND t.case_id = :case_id', 'params' => array(':project_id' => $project_id, ':case_id' => $case_id)));
}