コード例 #1
0
 function object_subtypes()
 {
     if (!logged_user()->isAdminGroup()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $co_types = array();
     $managers = array("tasks" => "ProjectTasks");
     foreach ($managers as $title => $manager) {
         $co_types[$manager] = ProjectCoTypes::getObjectTypesByManager($manager);
     }
     tpl_assign('managers', $managers);
     tpl_assign('co_types', $co_types);
     $object_subtypes = array_var($_POST, 'subtypes');
     if (is_array($object_subtypes)) {
         try {
             DB::beginWork();
             foreach ($object_subtypes as $manager => $subtypes) {
                 foreach ($subtypes as $subtype) {
                     $type = ProjectCoTypes::findById(array_var($subtype, 'id', 0));
                     if (!$type instanceof ProjectCoType) {
                         $type = new ProjectCoType();
                         $type->setObjectManager($manager);
                     }
                     if (!array_var($subtype, 'deleted')) {
                         $type->setName(array_var($subtype, 'name', ''));
                         $type->save();
                     } else {
                         eval('$man_instance = ' . $manager . "::instance();");
                         if ($man_instance instanceof ProjectDataObjects && array_var($subtype, 'id', 0) > 0) {
                             $objects = $man_instance->findAll(array('conditions' => "`object_subtype`=" . array_var($subtype, 'id', 0)));
                             if (is_array($objects)) {
                                 foreach ($objects as $obj) {
                                     if ($obj instanceof DataObject) {
                                         $obj->setColumnValue('object_subtype', 0);
                                         $obj->save();
                                     }
                                 }
                             }
                         }
                         if ($type instanceof ProjectCoType) {
                             $type->delete();
                         }
                     }
                 }
             }
             DB::commit();
             flash_success(lang("success save object subtypes"));
             ajx_current("back");
         } catch (Exception $e) {
             DB::rollback();
             flash_error($e->getMessage());
             ajx_current("empty");
         }
     }
 }
コード例 #2
0
 private function get_ext_values($field, $manager = null)
 {
     $values = array(array('id' => '', 'name' => '-- ' . lang('select') . ' --'));
     if ($field == 'company_id' || $field == 'assigned_to_company_id') {
         $companies = Companies::getVisibleCompanies(logged_user());
         foreach ($companies as $company) {
             $values[] = array('id' => $company->getId(), 'name' => $company->getName());
         }
     } else {
         if ($field == 'user_id' || $field == 'created_by_id' || $field == 'updated_by_id' || $field == 'assigned_to_user_id' || $field == 'completed_by_id') {
             $users = Users::getVisibleUsers(logged_user());
             foreach ($users as $user) {
                 $values[] = array('id' => $user->getId(), 'name' => $user->getDisplayName());
             }
         } else {
             if ($field == 'milestone_id') {
                 $milestones = ProjectMilestones::getActiveMilestonesByUser(logged_user());
                 foreach ($milestones as $milestone) {
                     $values[] = array('id' => $milestone->getId(), 'name' => $milestone->getName());
                 }
             } else {
                 if ($field == 'workspace') {
                     $workspaces = logged_user()->getWorkspaces(false, 0);
                     foreach ($workspaces as $ws) {
                         $values[] = array('id' => $ws->getId(), 'name' => $ws->getName());
                     }
                 } else {
                     if ($field == 'tag') {
                         $tags = Tags::getTagNames();
                         foreach ($tags as $tag) {
                             $values[] = array('id' => $tag['name'], 'name' => $tag['name']);
                         }
                     } else {
                         if ($field == 'object_subtype') {
                             $object_types = ProjectCoTypes::findAll(array('conditions' => !is_null($manager) ? "`object_manager`='{$manager}'" : ""));
                             foreach ($object_types as $object_type) {
                                 $values[] = array('id' => $object_type->getId(), 'name' => $object_type->getName());
                             }
                         }
                     }
                 }
             }
         }
     }
     return $values;
 }
コード例 #3
0
ファイル: task_list.php プロジェクト: Jtgadbois/Pedadida
	<?php if ($task_list->getDueDate()->getYear() > DateTimeValueLib::now()->getYear()) { ?> 
	  <div class="dueDate"><span class="bold"><?php echo lang('due date') ?>: </span><?php echo format_datetime($task_list->getDueDate(), null, 0) ?></div>
	<?php } else { ?> 
	  <div class="dueDate"><span class="bold"><?php echo lang('due date') ?>: </span>
	  <?php 
	  	echo format_descriptive_date($task_list->getDueDate());
	  	if ($task_list->getUseDueTime()) {
	  		echo ", " . format_time($task_list->getDueDate(), user_config_option('time_format_use_24') ? 'G:i' : 'g:i A');
	  	}
	  ?>
	  </div>
	<?php } ?>
<?php } ?>
		
<?php if ($task_list->getObjectSubtype() > 0) {
		$subType = ProjectCoTypes::findById($task_list->getObjectSubtype());
		if ($subType instanceOf ProjectCoType ) {
			echo "<div><span class='bold'>" . lang('object type') . ":</span> " . $subType->getName() . "</div>";
		}
	  }
?>

<?php if($task_list->getText()) { ?>
  <fieldset><legend><?php echo lang('description') ?></legend>
	<div class="wysiwyg-description"><?php
		if($task_list->getTypeContent() == "text"){
			echo escape_html_whitespace(convert_to_links(clean($task_list->getText())));
		}else{
			echo purify_html(nl2br($task_list->getText()));
		}
	?></div>
コード例 #4
0
 function get_co_types()
 {
     $object_type = array_var($_GET, 'object_type', '');
     if ($object_type != '') {
         $types = ProjectCoTypes::findAll(array("conditions" => "`object_manager` = " . DB::escape($object_type)));
         $co_types = array();
         foreach ($types as $type) {
             $t = array();
             $t['id'] = $type->getId();
             $t['name'] = $type->getName();
             $co_types[] = $t;
         }
         ajx_current("empty");
         ajx_extra_data(array("co_types" => $co_types));
     }
 }
コード例 #5
0
ファイル: add_task.php プロジェクト: Jtgadbois/Pedadida
						<a href="#" onclick="og.removePreviousTask(this.parentNode, '<?php echo $genid?>', '<?php echo $k?>')" class="removeDiv" style="display: block;"><?php echo lang('remove') ?></a>
					</div>
					<script>
						var obj={id:'<?php echo $task_dep->getPreviousTaskId() ?>'};
						og.previousTasks[og.previousTasks.length] = obj;
					</script>
				<?php $k++;
				}
			} ?>
			</div><a class="coViewAction ico-add" id="<?php echo $genid?>previous_before" href="#" onclick="og.pickPreviousTask(this, '<?php echo $genid?>',<?php echo $task->getId()?>)"><?php echo lang('add previous task') ?></a>
		
		</div>
		<?php } ?>
		
		<div style="padding-top:4px">
		<?php $task_types = ProjectCoTypes::getObjectTypesByManager('ProjectTasks');
			if (count($task_types) > 0) {
				echo label_tag(lang('object type'));
				echo select_object_type('task[object_subtype]', $task_types, array_var($task_data, 'object_subtype', config_option('default task co type')), array('tabindex' => '95', 'onchange' => "og.onChangeObjectCoType('$genid', '".$task->getObjectTypeId()."', ".($task->isNew() ? "0" : $task->getId()).", this.value)"));
			}
		?>
		</div>
  	</fieldset>
  	</div>

<?php if($task->isNew()) { ?>
	<?php if (isset($base_task) && $base_task instanceof ProjectTask && $base_task->getIsTemplate()) { ?>
		<input type="hidden" name="task[from_template_id]" value="<?php echo $base_task->getId() ?>" />
	<?php } ?>
<?php } // if ?>
  	
コード例 #6
0
 function new_list_tasks()
 {
     //load config options into cache for better performance
     load_user_config_options_by_category_name('task panel');
     // get query parameters, save user preferences if necessary
     $status = array_var($_GET, 'status', null);
     if (is_null($status) || $status == '') {
         $status = user_config_option('task panel status', 2);
     } else {
         if (user_config_option('task panel status') != $status) {
             set_user_config_option('task panel status', $status, logged_user()->getId());
         }
     }
     $previous_filter = user_config_option('task panel filter', 'assigned_to');
     $filter = array_var($_GET, 'filter');
     if (is_null($filter) || $filter == '') {
         $filter = user_config_option('task panel filter', 'assigned_to');
     } else {
         if (user_config_option('task panel filter') != $filter) {
             set_user_config_option('task panel filter', $filter, logged_user()->getId());
         }
     }
     if ($filter != 'no_filter') {
         $filter_value = array_var($_GET, 'fval');
         if (is_null($filter_value) || $filter_value == '') {
             $filter_value = user_config_option('task panel filter value', logged_user()->getCompanyId() . ':' . logged_user()->getId());
             set_user_config_option('task panel filter value', $filter_value, logged_user()->getId());
             $filter = $previous_filter;
             set_user_config_option('task panel filter', $filter, logged_user()->getId());
         } else {
             if (user_config_option('task panel filter value') != $filter_value) {
                 set_user_config_option('task panel filter value', $filter_value, logged_user()->getId());
             }
         }
     }
     $isJson = array_var($_GET, 'isJson', false);
     if ($isJson) {
         ajx_current("empty");
     }
     $project = active_project();
     $tag = active_tag();
     $template_condition = "`is_template` = 0 ";
     //Get the task query conditions
     $task_filter_condition = "";
     switch ($filter) {
         case 'assigned_to':
             $assigned_to = explode(':', $filter_value);
             $assigned_to_user = array_var($assigned_to, 1, 0);
             $assigned_to_company = array_var($assigned_to, 0, 0);
             if ($assigned_to_user > 0) {
                 $task_filter_condition = " AND (`assigned_to_user_id` = " . $assigned_to_user . " OR (`assigned_to_company_id` = " . $assigned_to_company . " AND `assigned_to_user_id` = 0)) ";
             } else {
                 if ($assigned_to_company > 0) {
                     $task_filter_condition = " AND  `assigned_to_company_id` = " . $assigned_to_company . " AND `assigned_to_user_id` = 0";
                 } else {
                     if ($assigned_to_company == -1 && $assigned_to_user == -1) {
                         $task_filter_condition = "  AND `assigned_to_company_id` = 0 AND `assigned_to_user_id` = 0 ";
                     }
                 }
             }
             break;
         case 'assigned_by':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `assigned_by_id` = " . $filter_value . " ";
             }
             break;
         case 'created_by':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `created_by_id` = " . $filter_value . " ";
             }
             break;
         case 'completed_by':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `completed_by_id` = " . $filter_value . " ";
             }
             break;
         case 'milestone':
             $task_filter_condition = " AND  `milestone_id` = " . $filter_value . " ";
             break;
         case 'priority':
             $task_filter_condition = " AND  `priority` = " . $filter_value . " ";
             break;
         case 'subtype':
             if ($filter_value != 0) {
                 $task_filter_condition = " AND  `object_subtype` = " . $filter_value . " ";
             }
             break;
         case 'no_filter':
             $task_filter_condition = "";
             break;
         default:
             flash_error(lang('task filter criteria not recognised', $filter));
     }
     if ($project instanceof Project) {
         $pids = $project->getAllSubWorkspacesQuery(true);
         $projectstr = " AND " . ProjectTasks::getWorkspaceString($pids);
     } else {
         $pids = "";
         $projectstr = "";
     }
     $permissions = " AND " . permissions_sql_for_listings(ProjectTasks::instance(), ACCESS_LEVEL_READ, logged_user());
     $task_status_condition = "";
     switch ($status) {
         case 0:
             // Incomplete tasks
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME);
             break;
         case 1:
             // Complete tasks
             $task_status_condition = " AND `completed_on` > " . DB::escape(EMPTY_DATETIME);
             break;
         case 10:
             // Active tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}'";
             break;
         case 11:
             // Overdue tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` < '{$now}'";
             break;
         case 12:
             // Today tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` = '{$now}'";
             break;
         case 13:
             // Today + Overdue tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
             break;
         case 14:
             // Today + Overdue tasks
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'";
             break;
         case 20:
             // Actives task by current user
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}' AND `assigned_to_user_id` = " . logged_user()->getId();
             break;
         case 21:
             // Subscribed tasks by current user
             $res20 = DB::execute("SELECT object_id FROM " . TABLE_PREFIX . "object_subscriptions WHERE `object_manager` LIKE 'ProjectTasks' AND `user_id` = " . logged_user()->getId());
             $subs_rows = $res20->fetchAll($res20);
             foreach ($subs_rows as $row) {
                 $subs[] = $row['object_id'];
             }
             unset($res20, $subs_rows, $row);
             $now = date('Y-m-j 00:00:00');
             $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `id` IN(" . implode(',', $subs) . ")";
             break;
         case 2:
             // All tasks
             break;
         default:
             throw new Exception('Task status "' . $status . '" not recognised');
     }
     if (!$tag) {
         $tagstr = "";
     } else {
         $tagstr = " AND (select count(*) from " . TABLE_PREFIX . "tags where " . TABLE_PREFIX . "project_tasks.id = " . TABLE_PREFIX . "tags.rel_object_id and " . TABLE_PREFIX . "tags.tag = " . DB::escape($tag) . " and " . TABLE_PREFIX . "tags.rel_object_manager ='ProjectTasks' ) > 0 ";
     }
     $conditions = $template_condition . $task_filter_condition . $task_status_condition . $permissions . $tagstr . $projectstr . " AND `trashed_by_id` = 0 AND `archived_by_id` = 0";
     //Now get the tasks
     $tasks = ProjectTasks::findAll(array('conditions' => $conditions, 'order' => 'created_on DESC', 'limit' => user_config_option('task_display_limit') > 0 ? user_config_option('task_display_limit') + 1 : null));
     ProjectTasks::populateData($tasks);
     //Find all internal milestones for these tasks
     $internalMilestones = ProjectMilestones::getProjectMilestones(active_or_personal_project(), null, 'DESC', "", null, null, null, $status == 0, false);
     ProjectMilestones::populateData($internalMilestones);
     //Find all external milestones for these tasks
     $milestone_ids = array();
     if ($tasks) {
         foreach ($tasks as $task) {
             if ($task->getMilestoneId() != 0) {
                 $milestone_ids[$task->getMilestoneId()] = $task->getMilestoneId();
             }
         }
     }
     $milestone_ids_condition = '';
     if (count($milestone_ids) > 0) {
         $milestone_ids_condition = ' OR id in (' . implode(',', $milestone_ids) . ')';
     }
     if ($status == 0) {
         $pendingstr = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " ";
     } else {
         $pendingstr = "";
     }
     if (!$tag) {
         $tagstr = "";
     } else {
         $tagstr = " AND (select count(*) from " . TABLE_PREFIX . "tags where " . TABLE_PREFIX . "project_milestones.id = " . TABLE_PREFIX . "tags.rel_object_id and " . TABLE_PREFIX . "tags.tag = " . DB::escape($tag) . " and " . TABLE_PREFIX . "tags.rel_object_manager ='ProjectMilestones' ) > 0 ";
     }
     $projectstr = " AND (" . ProjectMilestones::getWorkspaceString($pids) . $milestone_ids_condition . ")";
     $archivedstr = " AND `archived_by_id` = 0 ";
     $milestone_conditions = " `is_template` = false " . $archivedstr . $projectstr . $pendingstr;
     $externalMilestonesTemp = ProjectMilestones::findAll(array('conditions' => $milestone_conditions));
     $externalMilestones = array();
     if ($externalMilestonesTemp) {
         foreach ($externalMilestonesTemp as $em) {
             $found = false;
             if ($internalMilestones) {
                 foreach ($internalMilestones as $im) {
                     if ($im->getId() == $em->getId()) {
                         $found = true;
                         break;
                     }
                 }
             }
             if (!$found) {
                 $externalMilestones[] = $em;
             }
         }
     }
     ProjectMilestones::populateData($externalMilestones);
     //Get Users Info
     if (logged_user()->isMemberOfOwnerCompany()) {
         $users = Users::getAll();
         $allUsers = array();
     } else {
         $users = logged_user()->getAssignableUsers();
         $allUsers = Users::getAll();
     }
     //Get Companies Info
     if (logged_user()->isMemberOfOwnerCompany()) {
         $companies = Companies::getCompaniesWithUsers();
     } else {
         $companies = logged_user()->getAssignableCompanies();
     }
     if (!$isJson) {
         if (active_project() instanceof Project) {
             $task_templates = WorkspaceTemplates::getTemplatesByWorkspace(active_project()->getId());
         } else {
             $task_templates = array();
         }
         tpl_assign('project_templates', $task_templates);
         tpl_assign('all_templates', COTemplates::findAll());
         if (user_config_option('task_display_limit') > 0 && count($tasks) > user_config_option('task_display_limit')) {
             tpl_assign('displayTooManyTasks', true);
             array_pop($tasks);
         }
         tpl_assign('tasks', $tasks);
         tpl_assign('object_subtypes', ProjectCoTypes::getObjectTypesByManager('ProjectTasks'));
         tpl_assign('internalMilestones', $internalMilestones);
         tpl_assign('externalMilestones', $externalMilestones);
         tpl_assign('users', $users);
         tpl_assign('allUsers', $allUsers);
         tpl_assign('companies', $companies);
         tpl_assign('userPreferences', array('filterValue' => isset($filter_value) ? $filter_value : '', 'filter' => $filter, 'status' => $status, 'showWorkspaces' => user_config_option('tasksShowWorkspaces', 1), 'showTime' => user_config_option('tasksShowTime', 0), 'showDates' => user_config_option('tasksShowDates', 0), 'showTags' => user_config_option('tasksShowTags', 0), 'showEmptyMilestones' => user_config_option('tasksShowEmptyMilestones', 0), 'groupBy' => user_config_option('tasksGroupBy', 'milestone'), 'orderBy' => user_config_option('tasksOrderBy', 'priority'), 'defaultNotifyValue' => user_config_option('can notify from quick add')));
         ajx_set_no_toolbar(true);
     }
 }
コード例 #7
0
 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return ProjectCoTypes 
  */
 function manager()
 {
     if (!$this->manager instanceof ProjectCoTypes) {
         $this->manager = ProjectCoTypes::instance();
     }
     return $this->manager;
 }
コード例 #8
0
    $report_data['show_billing'] = $has_billing;
}
if (array_var($report_data, "project_id") != null) {
    $project_id = array_var($report_data, "project_id", 0);
} else {
    if (active_project() instanceof Project) {
        $project_id = active_project()->getId();
    }
}
if (!array_var($report_data, 'date_type')) {
    $report_data['date_type'] = 1;
}
if (!isset($conditions)) {
    $conditions = array();
}
$object_subtypes = ProjectCoTypes::getObjectTypesByManager("ProjectTasks");
?>
<form style='height:100%;background-color:white' class="internalForm" action="<?php 
echo get_url('reporting', 'total_task_times');
?>
" method="post" enctype="multipart/form-data">

<div class="reportTotalTimeParams">
<div class="coInputHeader">
	<div class="coInputHeaderUpperRow">
		<div class="coInputTitle"><?php 
echo lang('task time report');
?>
		<?php 
echo submit_button(lang('generate report'), 's', array('style' => 'margin-top:0px;margin-left:10px'));
?>
コード例 #9
0
 /**
 * Return manager instance
 *
 * @access protected
 * @param void
 * @return ProjectCoTypes 
 */
 function manager() {
   if(!($this->manager instanceof ProjectCoTypes)) $this->manager = ProjectCoTypes::instance();
   return $this->manager;
 } // manager
コード例 #10
0
 /**
  * This function will return paginated result. Result is an array where first element is 
  * array of returned object and second populated pagination object that can be used for 
  * obtaining and rendering pagination data using various helpers.
  * 
  * Items and pagination array vars are indexed with 0 for items and 1 for pagination
  * because you can't use associative indexing with list() construct
  *
  * @access public
  * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
  * @param integer $items_per_page Number of items per page
  * @param integer $current_page Current page number
  * @return array
  */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
 {
     if (isset($this) && instance_of($this, 'ProjectCoTypes')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return ProjectCoTypes::instance()->paginate($arguments, $items_per_page, $current_page);
         //$instance =& ProjectCoTypes::instance();
         //return $instance->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }
コード例 #11
0
 static function getExternalColumnValue($field, $id)
 {
     $value = '';
     if ($field == 'company_id' || $field == 'assigned_to_company_id') {
         $company = Companies::findById($id);
         if ($company instanceof Company) {
             $value = $company->getName();
         }
     } else {
         if ($field == 'user_id' || $field == 'created_by_id' || $field == 'updated_by_id' || $field == 'assigned_to_user_id' || $field == 'completed_by_id') {
             $user = Users::findById($id);
             if ($user instanceof User) {
                 $value = $user->getUsername();
             }
         } else {
             if ($field == 'milestone_id') {
                 $milestone = ProjectMilestones::findById($id);
                 if ($milestone instanceof ProjectMilestone) {
                     $value = $milestone->getName();
                 }
             } else {
                 if ($field == 'object_subtype') {
                     $object_subtype = ProjectCoTypes::findById($id);
                     if ($object_subtype instanceof ProjectCoType) {
                         $value = $object_subtype->getName();
                     }
                 }
             }
         }
     }
     return $value;
 }