/**
  * 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'));
     }
 }
 public function postProjects()
 {
     $projects = new Projects();
     $name = Input::get('inputName');
     $technologies = Input::get('inputTechnologies');
     $description = Input::get('inputDescription');
     $created_at = date("Y-m-d H:i:s");
     $updated_at = date("Y-m-d H:i:s");
     $projects->insertProjects($name, $technologies, $description, $created_at, $updated_at);
     return Redirect::to('about/projects')->with('message', '<div class="alert alert-dismissable alert-success">
 				<strong>Well done!</strong> Project added successfully.</div>');
 }
Exemplo n.º 3
0
 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');
     }
 }
Exemplo n.º 4
0
 public static function singleton() {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c;
     }
     return self::$instance;
 }
Exemplo n.º 5
0
/**
 * Daily update of repositories
 *
 * @param null
 * @return void
 */
function source_handle_on_frequently()
{
    require_once ANGIE_PATH . '/classes/xml/xml2array.php';
    $results = 'Repositories updated: ';
    $repositories = Repositories::findByUpdateType(REPOSITORY_UPDATE_FREQUENTLY);
    foreach ($repositories as $repository) {
        // don't update projects other than active ones
        $project = Projects::findById($repository->getProjectId());
        if ($project->getStatus() !== PROJECT_STATUS_ACTIVE) {
            continue;
        }
        // if
        $repository->loadEngine();
        $repository_engine = new RepositoryEngine($repository, true);
        $last_commit = $repository->getLastCommit();
        $revision_to = is_null($last_commit) ? 1 : $last_commit->getRevision() + 1;
        $logs = $repository_engine->getLogs($revision_to);
        if (!$repository_engine->has_errors) {
            $repository->update($logs['data']);
            $total_commits = $logs['total'];
            $results .= $repository->getName() . ' (' . $total_commits . ' new commits); ';
            if ($total_commits > 0) {
                $repository->sendToSubscribers($total_commits, $repository_engine);
                $repository->createActivityLog($total_commits);
            }
            // if
        }
        // if
    }
    // foreach
    return is_foreachable($repositories) && count($repositories) > 0 ? $results : 'No repositories for frequently update';
}
Exemplo n.º 6
0
 /**
  * Return project part of the relationship
  *
  * @param void
  * @return Project
  */
 function getProject()
 {
     if (is_null($this->project)) {
         $this->project = Projects::findById($this->getProjectId());
     }
     // if
     return $this->project;
 }
Exemplo n.º 7
0
 /**
  * Return project instance
  *
  * @param void
  * @return Project
  */
 function getProject()
 {
     if ($this->project === false) {
         $this->project = Projects::findById($this->getProjectId());
     }
     // if
     return $this->project;
 }
 /**
  * Return number of projects that are in this group
  *
  * @param void
  * @return integer
  */
 function getProjectsCount()
 {
     if ($this->projects_count === false) {
         $this->projects_count = Projects::countByGroup($this);
     }
     // if
     return $this->projects_count;
 }
Exemplo n.º 9
0
 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);
 }
	/**
	 * Show reporting index page
	 *
	 * @param void
	 * @return null
	 */
	function add_chart() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		$factory = new ProjectChartFactory();
		$types = $factory->getChartTypes();

		$chart_data = array_var($_POST, 'chart');
		if(!is_array($chart_data)) {
			$chart_data = array(
				'type_id' => 1,
				'display_id' => 20,
				'show_in_project' => 1,
				'show_in_parents' => 0
			); // array
		} // if
		tpl_assign('chart_data', $chart_data);


		if (is_array(array_var($_POST, 'chart'))) {
			$project = Projects::findById(array_var($chart_data, 'project_id'));
			if (!$project instanceof Project) {
				flash_error(lang('project dnx'));
				ajx_current("empty");
				return;
			}
			$chart = $factory->getChart(array_var($chart_data, 'type_id'));
			$chart->setDisplayId(array_var($chart_data, 'display_id'));
			$chart->setTitle(array_var($chart_data, 'title'));

			if (array_var($chart_data, 'save') == 1){
				$chart->setFromAttributes($chart_data);

				try {
					DB::beginWork();
					$chart->save();
					$chart->setProject($project);
					DB::commit();
					flash_success(lang('success add chart', $chart->getTitle()));
					ajx_current('back');
				} catch(Exception $e) {
					DB::rollback();
					flash_error($e->getMessage());
					ajx_current("empty");
				}
				return;
			}

			$chart->ExecuteQuery();
			tpl_assign('chart', $chart);
			ajx_replace(true);
		}
		tpl_assign('chart_displays', $factory->getChartDisplays());
		tpl_assign('chart_list', $factory->getChartTypes());
	}
Exemplo n.º 11
0
	/**
	 * This function will return application data object that matches action and in object ID
	 *
	 * @param void
	 * @return ApplicationDataObject
	 */
	function getInObject() {
		if(is_null($this->in_object)) {
			if($this->getAction() == self::ADD_COMMENT_ACTION) {
				$this->in_object = ProjectMessages::findById($this->getInObjectId());
			} elseif($this->getAction() == self::ADD_TASK_ACTION) {
				$this->in_object = Projects::findById($this->getInObjectId());
			} // if
		} // if
		return $this->in_object;
	} // getInObject
 /**
  * Construct PublicSubmitAdminController
  * 
  * @param string $request
  * @return PublicSubmitAdminController
  *
  */
 function __construct($request)
 {
     parent::__construct($request);
     $this->smarty->assign(array("public_submit_settings_url" => assemble_url('admin_settings_public_submit')));
     if (!(extension_loaded('gd') || extension_loaded('gd2')) || !function_exists('imagefttext')) {
         $this->gd_loaded = false;
     }
     // if
     $this->smarty->assign(array('public_submit_url' => assemble_url('public_submit'), 'public_submit_enabled' => ConfigOptions::getValue('public_submit_enabled'), 'public_submit_captcha_enabled' => ConfigOptions::getValue('public_submit_enable_captcha'), 'public_submit_project' => Projects::findById(ConfigOptions::getValue('public_submit_default_project')), 'gd_loaded' => $this->gd_loaded));
     return $this;
 }
 /**
  * Mobile Access Homepage
  *
  */
 function index()
 {
     $pinned_project_ids = PinnedProjects::findProjectIdsByUser($this->logged_user);
     if (is_foreachable($pinned_project_ids)) {
         $pinned_projects = Projects::findByIds($pinned_project_ids);
     } else {
         $pinned_projects = null;
     }
     // if
     $this->smarty->assign(array("pinned_projects" => $pinned_projects));
 }
Exemplo n.º 14
0
 public function actionStart()
 {
     $model = new Projects();
     // uncomment the following code to enable ajax-based validation
     /*
     if(isset($_POST['ajax']) && $_POST['ajax']==='projects-start-form')
     {
     	echo CActiveForm::validate($model);
     	Yii::app()->end();
     }
     */
     if (isset($_POST['Projects'])) {
         $model->attributes = $_POST['Projects'];
         $model->creationDateTime = date('Y-m-d H:i:s');
         if ($model->validate()) {
             $model->save();
             $this->redirect('industry/index');
         }
     }
     $this->render('start', array('model' => $model));
 }
 /**
  * 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));
     }
 }
Exemplo n.º 16
0
 /**
  * Init active project, if we have active_project $_GET var
  *
  * @access public
  * @param void
  * @return null
  * @throws Error
  */
 private function initActiveProject()
 {
     $project_id = array_var($_GET, 'active_project');
     if (!empty($project_id)) {
         $project = Projects::findById($project_id);
         if (!$project instanceof Project) {
             throw new Error(lang('failed to load project'));
         }
         // if
         $this->setProject($project);
     }
     // if
 }
 /**
  * Constructor
  *
  * @param Request $request
  * @return MobileAccessController extends ApplicationController 
  */
 function __construct($request)
 {
     parent::__construct($request);
     $this->disableCategories();
     $project_id = $this->request->get('project_id');
     if ($project_id) {
         $this->active_project = Projects::findById($project_id);
     }
     // if
     if (!instance_of($this->active_project, 'Project')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->logged_user->isProjectMember($this->active_project)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     if ($this->active_project->getType() == PROJECT_TYPE_SYSTEM) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $this->project_sections = array();
     $this->project_sections[] = array("name" => "overview", "full_name" => lang("Overview"), "url" => assemble_url('mobile_access_view_project', array('project_id' => $this->active_project->getId())));
     if (module_loaded('discussions') && $this->logged_user->getProjectPermission('discussion', $this->active_project)) {
         $this->project_sections[] = array("name" => "discussions", "full_name" => lang("Discussions"), "url" => assemble_url('mobile_access_view_discussions', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('milestones') && $this->logged_user->getProjectPermission('milestone', $this->active_project)) {
         $this->project_sections[] = array("name" => "milestones", "full_name" => lang("Milestones"), "url" => assemble_url('mobile_access_view_milestones', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('files') && $this->logged_user->getProjectPermission('file', $this->active_project)) {
         $this->project_sections[] = array("name" => "files", "full_name" => lang("Files"), "url" => assemble_url('mobile_access_view_files', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('checklists') && $this->logged_user->getProjectPermission('checklist', $this->active_project)) {
         $this->project_sections[] = array("name" => "checklists", "full_name" => lang("Checklists"), "url" => assemble_url('mobile_access_view_checklists', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('pages') && $this->logged_user->getProjectPermission('page', $this->active_project)) {
         $this->project_sections[] = array("name" => "pages", "full_name" => lang("Pages"), "url" => assemble_url('mobile_access_view_pages', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('tickets') && $this->logged_user->getProjectPermission('ticket', $this->active_project)) {
         $this->project_sections[] = array("name" => "tickets", "full_name" => lang("Tickets"), "url" => assemble_url('mobile_access_view_tickets', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('timetracking') && $this->logged_user->getProjectPermission('timerecord', $this->active_project)) {
         $this->project_sections[] = array("name" => "timetracking", "full_name" => lang("Time"), "url" => assemble_url('mobile_access_view_timerecords', array('project_id' => $this->active_project->getId())));
     }
     if (module_loaded('source') && $this->logged_user->getProjectPermission('repository', $this->active_project)) {
         $this->project_sections[] = array("name" => "source", "full_name" => lang("Repositories"), "url" => assemble_url('mobile_access_view_repositories', array('project_id' => $this->active_project->getId())));
     }
     //if($this->active_project->isLoaded() && $this->enable_categories) {
     $this->addBreadcrumb(lang('Project'), assemble_url('mobile_access_view_project', array("project_id" => $this->active_project->getId())));
     $this->smarty->assign(array("page_title" => $this->active_project->getName(), "active_project" => $this->active_project, "project_sections" => $this->project_sections, "page_breadcrumbs" => $this->breadcrumbs, "active_project_section" => 'overview', "active_category" => $this->active_category));
 }
 function set_responsible_status()
 {
     $project_id = $this->request->getId('project_id');
     if ($project_id) {
         $project = Projects::findById($project_id);
     }
     $ticket_id = $this->request->getId('ticket_id');
     if ($ticket_id) {
         $ticket = Tickets::findByTicketId($project, $ticket_id);
     }
     $owner = Assignments::findOwnerByObject($ticket);
     $users = Assignments::findAssigneesByObject($ticket);
     $this->smarty->assign(array('project' => $project, 'ticket' => $ticket, 'users' => $users, 'owner' => $owner, 'ticket_url' => assemble_url('project_ticket', array('project_id' => $project_id, 'ticket_id' => $ticket_id))));
 }
Exemplo n.º 19
0
 /**
  * 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.'));
     }
 }
 /**
  * Returns all Workspaces an Template belongs to
  *
  * @param $object_manager
  * @param $Template_id
  * @return array
  */
 static function getWorkspacesByTemplate($template_id, $wsCSV = null)
 {
     $all = self::findAll(array('conditions' => "`template_id` = {$template_id}" . ($wsCSV ? " AND `workspace_id` IN ({$wsCSV})" : '')));
     if (!is_array($all)) {
         return array();
     }
     $csv = "";
     foreach ($all as $w) {
         if ($csv != "") {
             $csv .= ",";
         }
         $csv .= $w->getWorkspaceId();
     }
     return Projects::findByCSVIds($csv);
 }
Exemplo n.º 21
0
 /**
  * Class constructor
  *
  */
 function __construct($repository, $triggered_by_handler = false)
 {
     parent::__construct();
     // check if we have neccessary resources
     if (instance_of($repository, 'Repository')) {
         $this->active_repository = $repository;
         $this->active_project = Projects::findById($repository->getProjectId());
     }
     // if
     $this->executable_path = with_slash(ConfigOptions::getValue('source_svn_path'));
     $config_dir = ConfigOptions::getValue('source_svn_config_dir');
     $this->config_dir = is_null($config_dir) ? '' : '--config-dir ' . $config_dir;
     $this->stderr2stdout = ConfigOptions::getValue('source_svn_use_output_redirect') == true ? "2>&1" : "";
     $this->trust_server_certificate = ConfigOptions::getValue('source_svn_trust_server_cert') == true ? '--trust-server-cert' : '';
     $this->triggerred_by_handler = $triggered_by_handler;
 }
 /**
  * Returns all Workspaces an Object belongs to
  *
  * @param $object_manager
  * @param $object_id
  * @return array
  */
 static function getWorkspacesByObject($object_manager, $object_id, $wsCSV = null)
 {
     $all = self::findAll(array('conditions' => "`object_manager` = '{$object_manager}' AND `object_id` = {$object_id}" . ($wsCSV ? " AND `workspace_id` IN ({$wsCSV})" : '')));
     //array('`object_manager` = ? AND `object_id` = ?', $object_manager, $object_id)));
     if (!is_array($all) || count($all) == 0) {
         return array();
     }
     $csv = "";
     foreach ($all as $w) {
         if ($csv != "") {
             $csv .= ",";
         }
         $csv .= $w->getWorkspaceId();
     }
     return Projects::findByCSVIds($csv);
 }
 /**
  * Return all groups ordered by name
  * 
  * This function will return only groups visible to given user
  * 
  * If $return_all is set to true all groups will be loaded and returned. 
  * This is used in situations where we need all of them regardels of user 
  * previous assignments (like select project group helper)
  *
  * @param User $user
  * @param boolean $return_all
  * @return array
  */
 function findAll($user, $return_all = false)
 {
     if ($return_all || $user->isAdministrator() || $user->isProjectManager()) {
         return ProjectGroups::find(array('order' => 'name'));
     }
     // if
     $project_ids = Projects::findProjectIdsByUser($user);
     if (is_foreachable($project_ids)) {
         $projects_table = TABLE_PREFIX . 'projects';
         $project_groups_table = TABLE_PREFIX . 'project_groups';
         return ProjectGroups::findBySQL("SELECT DISTINCT {$project_groups_table}.* FROM {$projects_table}, {$project_groups_table} WHERE {$project_groups_table}.id = {$projects_table}.group_id AND {$projects_table}.id IN (?) ORDER BY {$project_groups_table}.name", array($project_ids));
     } else {
         return null;
     }
     // if
 }
Exemplo n.º 24
0
 /**
  * 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);
                     }
                 }
             }
         }
     }
 }
 /**
  * Display company details
  *
  */
 function company()
 {
     $current_company = Companies::findById($this->request->get('object_id'));
     if (!instance_of($current_company, 'Company')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$current_company->isOwner() && !in_array($current_company->getId(), $this->logged_user->visibleCompanyIds())) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $users = $current_company->getUsers($this->logged_user->visibleUserIds());
     if (!$current_company->isOwner()) {
         $projects = Projects::findByUserAndCompany($this->logged_user, $current_company);
     }
     $this->smarty->assign(array('current_company' => $current_company, 'current_company_users' => $users, 'current_company_projects' => $projects, "page_title" => $current_company->getName(), "page_back_url" => assemble_url('mobile_access_people')));
 }
Exemplo n.º 26
0
function getGroupTitle($field, $tsRow)
{
    $ts = $tsRow["ts"];
    switch ($field) {
        case 'id':
            if ($ts->getObjectManager() == 'Projects') {
                return $ts->getObject()->getName();
            } else {
                return $ts->getObject()->getTitle();
            }
        case 'user_id':
            return Users::getUserDisplayName($ts->getUserId());
        case 'project_id_0':
            return $tsRow["wsId0"] != 0 ? Projects::findById($tsRow["wsId0"])->getName() : '';
        case 'project_id_1':
            return $tsRow["wsId1"] != 0 ? Projects::findById($tsRow["wsId1"])->getName() : '';
        case 'project_id_2':
            return $tsRow["wsId2"] != 0 ? Projects::findById($tsRow["wsId2"])->getName() : '';
        case 'priority':
            if ($ts->getObjectManager() == 'ProjectTasks') {
                switch ($ts->getObject()->getPriority()) {
                    case 100:
                        return lang('low priority');
                    case 200:
                        return lang('normal priority');
                    case 300:
                        return lang('high priority');
                    case 400:
                        return lang('urgent priority');
                    default:
                        return $ts->getObject()->getPriority();
                }
            } else {
                return lang('not applicable');
            }
        case 'milestone_id':
            if ($ts->getObjectManager() == 'ProjectTasks') {
                return $ts->getObject()->getMilestoneId() != 0 ? $ts->getObject()->getMilestone()->getTitle() : '';
            } else {
                return '';
            }
    }
    return '';
}
 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;
 }
 function form_run()
 {
     if ($this->request->isAsyncCall()) {
         $project = $this->request->get('project_id') ? Projects::findById($this->request->get('project_id')) : null;
         if ($project instanceof Project) {
             // TODO: eliminare group_by
             $report = new MilestoneETAReport($project);
             $this->response->assign('rendered_report_result', $report->render($this->logged_user));
             $this->response->assign('milestones', $report->getMilestones());
             $this->response->assign('detailed_report', true);
         } else {
             $this->response->notFound();
         }
         // if
     } else {
         $this->response->badRequest();
     }
     //if
 }
Exemplo n.º 29
0
 /**
  * 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;
 }
Exemplo n.º 30
0
 /**
  * Return all projects that this user is part of
  *
  * @access public
  * @param User $user
  * @param 
  * @return array
  */
 function getProjectsByUser(User $user, $additional_conditions = null)
 {
     $projects_table = Projects::instance()->getTableName(true);
     $project_users_table = ProjectUsers::instance()->getTableName(true);
     $projects = array();
     $sql = "SELECT {$projects_table}.* FROM {$projects_table}, {$project_users_table} WHERE ({$projects_table}.`id` = {$project_users_table}.`project_id` AND {$project_users_table}.`user_id` = " . DB::escape($user->getId()) . ')';
     if (trim($additional_conditions) != '') {
         $sql .= " AND ({$additional_conditions})";
     }
     // if
     $sql .= " ORDER BY {$projects_table}.`name`";
     $rows = DB::executeAll($sql);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $projects[] = Projects::instance()->loadFromRow($row);
         }
         // foreach
     }
     // if
     return count($projects) ? $projects : null;
 }