本文整理汇总了PHP中Projects::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Projects::model方法的具体用法?PHP Projects::model怎么用?PHP Projects::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projects
的用法示例。
在下文中一共展示了Projects::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionChangeStatus
/**
* Change Case status using select-box
*/
public function actionChangeStatus()
{
// check if user has permissions to changeStatusCases
if (Yii::app()->user->checkAccess('changeStatusCases')) {
// verify is request was made via post ajax
if (Yii::app()->request->isAjaxRequest && isset($_POST)) {
// get Cases object model
$model = $this->loadModel($_REQUEST['id']);
// set new status
$model->status_id = $_POST['changeto'];
// validate and save
if ($model->save()) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CaseStatusChanged', 'log_resourceid' => $model->case_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
Logs::model()->saveLog($attributes);
// create comment to let then know that some user change the case status
$modelComment = new Comments();
$modelComment->comment_date = date("Y-m-d G:i:s");
$modelComment->comment_text = Status::STATUS_COMMENT . ": " . $model->Status->status_id;
$modelComment->user_id = Yii::app()->user->id;
$modelComment->module_id = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $this->getId())))->module_id;
$modelComment->comment_resourceid = $model->case_id;
$modelComment->save(false);
// prepare email template for each project manager
Yii::import('application.extensions.phpMailer.yiiPhpMailer');
$mailer = new yiiPhpMailer();
$subject = Yii::t('email', 'CaseStatusChange') . " - " . $model->case_name;
//$Users = Users::model()->with('Clients')->findManagersByProject($model->project_id);
$Users = Projects::model()->findAllUsersByProject($model->project_id);
$recipientsList = array();
foreach ($Users as $client) {
$recipientsList[] = array('name' => $client->CompleteName, 'email' => $client->user_email);
}
// load template
$str = $this->renderPartial('//templates/cases/StatusChanged', array('case' => $model, 'user' => Users::model()->findByPk(Yii::app()->user->id), 'urlToCase' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->createUrl('cases/view', array('id' => $model->case_id)), 'typeNews' => $model->status_id == Status::STATUS_ACCEPTED || $model->status_id == Status::STATUS_TOREVIEW ? 'buenas' : 'malas', 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->request->baseUrl), true);
$mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL);
$output = Yii::t('cases', 'StatusChanged');
} else {
$output = Yii::t('cases', 'StatusError');
}
echo $output;
Yii::app()->end();
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例2: actionProfile
public function actionProfile()
{
$username = Yii::app()->Ini->v('user');
$current_user_id = 0;
$current_user_role = 0;
$model = Homeowners::model()->findByAttributes(array('username' => $username));
if (count($model) > 0) {
if (!Yii::app()->user->isGuest) {
$current_user_id = Yii::app()->user->getId();
$current_user_role = Yii::app()->user->role;
}
$criteria = new CDbCriteria();
$criteria->condition = "homeowner_id = " . $model->homeowner_id;
$criteria->limit = 8;
$this->pageTitle = 'Handyman.com - Homeowner - ' . $model->firstname . ' ' . $model->lastname . ' Profile';
$this->render('homeowner-profile', array('model' => $model, 'projects' => Projects::model()->findAll($criteria), 'current_user_id' => $current_user_id, 'current_user_role' => $current_user_role));
//update views
if (!Yii::app()->user->isGuest) {
$userid = Yii::app()->user->getId();
$role = Yii::app()->user->role;
$views = HomeownerViews::model()->findByAttributes(array('viewed_by' => $userid, 'homeowner_id' => $model->homeowner_id, 'viewed_user_type' => $role));
if (count($views) > 0) {
} else {
$views = new HomeownerViews();
$views->homeowner_id = $model->homeowner_id;
$views->viewed_by = $userid;
$views->viewed_user_type = $role;
$views->save();
}
}
} else {
$this->redirect(Yii::app()->homeUrl . 'home/error');
}
}
示例3: beforeAction
public function beforeAction($action)
{
$o_db = Settings::model()->findAll();
foreach ($o_db as $item) {
$this->settings[$item->alias] = $item->value;
}
$this->project = Projects::model()->getProjectByDomain($_SERVER['HTTP_HOST']);
return parent::beforeAction($action);
}
示例4: getStatistics
/**
* Get all task waiting to solve
* By default project_id is selected
* @return model list of invoices statistics amounts
*/
public function getStatistics()
{
if (Yii::app()->user->getState('project_selected') != null) {
return Invoices::model()->getInvoicesStatistics(Yii::app()->user->getState('project_selected'));
} else {
$Projects = Projects::model()->findMyProjects(Yii::app()->user->id);
$projectList = array(0);
foreach ($Projects as $project) {
array_push($projectList, $project->project_id);
}
return Invoices::model()->getInvoicesStatistics(implode(",", $projectList));
}
}
示例5: actionStatus
/**
* Change Project status action
*/
public function actionStatus()
{
if (Yii::app()->request->getParam('id') && ($model = Projects::model()->byUser()->findByPk(Yii::app()->request->getParam('id')))) {
// Check it's current status and update
$currentStatus = $model->status;
$model->status = $currentStatus == 0 ? 1 : 0;
// Add description to the activity
$model->activity['description'] = $model->status ? 'Project Activated.' : 'Project Archived.';
$model->update();
Functions::ajaxString($model->status ? Yii::t('projects', 'Project Activated.') : Yii::t('projects', 'Project Archived.'));
} else {
Functions::ajaxError(Yii::t('error', 'We could not find that project.'));
}
}
示例6: init
/**
* Initializes the controller.
*/
public function init()
{
parent::init();
if (!isset(Yii::app()->request->cookies['sel_lang'])) {
Yii::app()->request->cookies['sel_lang'] = new CHttpCookie('sel_lang', 'en_us');
Yii::app()->lc->setLanguage(Yii::app()->request->cookies['sel_lang']->value);
} else {
if (isset($_REQUEST['lc']) && !empty($_REQUEST['lc'])) {
Yii::app()->request->cookies['sel_lang'] = new CHttpCookie('sel_lang', $_REQUEST['lc']);
}
if (in_array(strtolower(Yii::app()->request->cookies['sel_lang']->value), Yii::app()->params['languages'])) {
Yii::app()->lc->setLanguage(Yii::app()->request->cookies['sel_lang']->value);
}
}
if (isset($_GET['infoproject']) && !empty($_GET['infoproject']) && Users::model()->verifyUserInProject((int) Yii::app()->request->getParam("infoproject", 0), Yii::app()->user->id)) {
Yii::app()->user->setState('project_selected', Yii::app()->request->getParam("infoproject", 0));
Yii::app()->user->setState('project_selectedName', Projects::model()->findByPk(Yii::app()->user->getState('project_selected'))->project_name);
$this->redirect(Yii::app()->createUrl('site'));
}
$avoid = array('companies');
if (Yii::app()->user->getState('project_selected') == null && Yii::app()->controller->id != null && !empty(Yii::app()->controller->ActionParams['id']) && !in_array(Yii::app()->controller->id, $avoid)) {
// Finding module class name
$criteria = new CDbCriteria();
$criteria->compare('module_name', Yii::app()->controller->id);
$module = Modules::model()->find($criteria);
if (isset($module->module_className) && class_exists($module->module_className)) {
// create class instance
$className = $module->module_className;
$instance = new $className();
// finding model record
$criteria = new CDbCriteria();
$criteria->compare($instance->getMetaData()->tableSchema->primaryKey, Yii::app()->controller->ActionParams['id']);
$model = $instance->find($criteria);
if ($model !== null) {
// finding model relations
$relations = $model->getMetaData()->relations;
if (array_key_exists("Projects", $relations) || $module->module_className == "Projects") {
if (Users::model()->verifyUserInProject($model->project_id, Yii::app()->user->id)) {
Yii::app()->user->setState('project_selected', $model->project_id);
Yii::app()->user->setState('project_selectedName', Projects::model()->findByPk($model->project_id)->project_name);
}
}
}
}
}
}
示例7: getProjectsProgress
public function getProjectsProgress()
{
if (Yii::app()->user->getState('project_selected') == null) {
// seleccionar todos los proyectos del usuario
$ProjectsList = Projects::model()->findMyProjects(Yii::app()->user->id);
$data = array();
// iterar cada proyecto
foreach ($ProjectsList as $project) {
// buscando todas las tareas relacionadas al proyecto iterado
$TasksList = Projects::model()->getProjectProgress($project->project_id);
$data[] = array('name' => ECHtml::word_split($project->project_name, 10), 'data' => array(!empty($TasksList->progress) ? round($TasksList->progress, 2) : 0));
}
} else {
// buscando todas las tareas relacionadas al proyecto seleccionado
$TasksList = Projects::model()->getProjectProgress(Yii::app()->user->getState('project_selected'));
$data[] = array('name' => ECHtml::word_split(Projects::model()->findByPk(Yii::app()->user->getState('project_selected'))->project_name, 10), 'data' => array(!empty($TasksList->progress) ? round($TasksList->progress, 2) : 0));
}
return $data;
}
示例8: getCalendarEvents
/**
* Get all projects events (milestones)
* By default project_id is selected
* @return model list milestones
*/
public function getCalendarEvents()
{
if (Yii::app()->user->getState('project_selected') != null) {
$projects = Yii::app()->user->getState('project_selected');
} else {
$WorkingProjects = Projects::model()->findMyProjects(Yii::app()->user->id);
$projectList = array();
foreach ($WorkingProjects as $project) {
array_push($projectList, $project->project_id);
}
$projects = implode(",", $projectList);
}
// Finding all projects milestones
$Milestones = Milestones::model()->findAll(array('condition' => 't.project_id IN (:project_id)', 'params' => array('project_id' => $projects)));
// Creating event format required by fullcalendar component
$arrayOfEvents = array();
foreach ($Milestones as $milestone) {
array_push($arrayOfEvents, array('title' => $milestone->milestone_title, 'start' => CHtml::encode(Yii::app()->dateFormatter->format('yyyy-MM-dd', $milestone->milestone_duedate)), 'end' => CHtml::encode(Yii::app()->dateFormatter->format('yyyy-MM-dd', $milestone->milestone_duedate)), 'description' => $milestone->milestone_description, 'className' => 'holiday'));
}
return $arrayOfEvents;
}
示例9: Header
function Header()
{
$client = Clients::model()->with('company')->findByPk(Yii::app()->user->clientID);
$project = Projects::model()->findByPk(Yii::app()->user->projectID);
$projectId = Yii::app()->user->projectID;
//Logo
//$this->Image('logo_pb.png',10,8,33);
//Arial bold 15
$this->SetFont('Arial','',12);
$this->SetXY(5,5);
//$this->Cell(20,10,$client->company->Company_Name.' - '.$project->Project_Name ,0,0,'L');
$this->SetXY(5,5);
$this->SetFont('Arial','B',12);
$this->Cell(0,0, Helper::shortenString($client->company->Company_Name,30).' - '.Helper::shortenString($project->Project_Name,20),0,1,'L');
$this->SetFont('Arial','',12);
$this->SetXY(5,10);
$this->Cell(0,0,"Export Summary:",0,1,'L');
// $this->Text(0,10,"AP Batch Summary Report: ");
$this->SetFont('Arial','B',12);
$this->SetXY(140,5);
if($this->doc_type == 'AP') {
$this->Cell(0,0,"AP Batch Summary Report:",0,1,'R');
} else {
$this->Cell(0,0,"PO Batch Summary Report:",0,1,'R');
}
$this->SetFont('Arial','',12);
$this->SetXY(140,10);
$this->Cell(0,0,"Batch ".$this->batch_id,0,1,'R');
//$this->SetXY(120,5);
//$this->Cell(0,0,"AP Batch Summary Report: ",0,0,'R');
$this->Line(5,14,205,14);
$this->Ln(5);
}
示例10: getProjectNameByID
public static function getProjectNameByID($prID){
$pr = Projects::model()->findByPk($prID);
return $pr->Project_Name;
}
示例11: array
<?php
// Items for dropdownlists
$status = ZHtml::enumItem(Projects::model(), 'status');
// Add default blank value for search fields.
$search_status = array('' => '') + $status;
?>
<div id="projects-list" class="table-main" style="display:none">
<?php
echo CHtml::form('', 'post', array('id' => 'export-form', 'enctype' => 'multipart/form-data'));
?>
<fieldset>
<input type="hidden" id="projects-list-csrf" value="<?php
echo Yii::app()->request->csrfToken;
?>
" />
<div class="table-header-block">
<div class="header-block-button">
<a id="projects-list-create-button" class="button round blue image-right ic-add text-upper" href="#">Create Project</a>
</div><!-- End Header Block Button -->
<div class="header-block-side">
<div class="page-nav">
<div class="page-count">
<span class="current-page" id="projects-list-part"></span>
<span class="all-page" id="projects-list-total"></span>
</div>
<div class="page-nav-arrow">
<a id="projects-list-prev" class="prev" href="#" title="Previous"><span class="icon"></span></a>
<a id="projects-list-next" class="next" href="#" title="Next"><span class="icon"></span></a>
示例12: 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'));
}
}
示例13: getMyProjects
public function getMyProjects()
{
return Projects::model()->findMyProjects(Yii::app()->user->id);
}
示例14: appendProjectsList
public function appendProjectsList ($client_id,$project_list){
if (is_array($project_list)) {
//add in condition here
$condition = new CDbCriteria();
$condition->addInCondition('Project_ID',$project_list);
$projects = Projects::model()->with($condition)->findAllByAttributes(array(
'Client_ID'=>$client_id
));
} else {
//selecting all projects
$projects = Projects::model()->findAllByAttributes(array(
'Client_ID'=>$client_id
));
}
$xml_proj = $this->xml->createElement("projects");
foreach ($projects as $project) {
$xml_row = $this->xml->createElement("row");
foreach ($project->attributes as $key => $value) {
$xml_field = $this->xml->createElement("field",htmlentities($value,ENT_QUOTES | 'ENT_XML1'));
$xml_field->setAttribute('name', $key);
$xml_row->appendChild($xml_field);
}
$xml_proj->appendChild($xml_row);
}
$this->wrapper->appendChild($xml_proj);
}
示例15: notifyNextUsers
public static function notifyNextUsers($nextUsers,$userToClient){
if ($nextUsers) {
$project = Projects::model()->findByPk(Yii::app()->user->projectID);
foreach ($nextUsers as $nextUser) {
$nextUserId = $nextUser->User_ID;
$nextUserApprovalValue = $nextUser->User_Approval_Value;
$user = Users::model()->with('settings','person')->findByPk($nextUserId);
// send notification
// get aps to approve to next users
$condition = new CDbCriteria();
$condition->join = "LEFT JOIN documents ON documents.Document_ID=t.Document_ID";
$condition->condition = "documents.Client_ID='" . Yii::app()->user->clientID . "'";
$condition->addCondition("documents.Project_ID = '" . Yii::app()->user->projectID . "'");
$condition->addCondition("t.AP_Approval_Value < '" . $nextUserApprovalValue . "'");
$condition->addCondition("t.AP_Approval_Value >= '" . $userToClient->User_Approval_Value . "'");
$condition->addCondition("t.AP_Approval_Value != '0'");
$aps = Aps::model()->find($condition);
if ($aps) {
$client = Clients::model()->findByPk(Yii::app()->user->clientID);
$clientsToApprove = array($client->company->Company_Name.' - '.$project->Project_Name);
Mail::sendPendingApprovalDocumentsNotification(!$user->settings->Notification,$user, $clientsToApprove, Documents::AP,$client,$project);
}
}
}
}