Example #1
0
 public function getCMSFields()
 {
     $fields = FieldList::create(HeaderField::create('Outer Captions'), $category = DropdownField::create('FeaturedWorkCategoryID', 'Category', ProjectCategory::get()->map('ID', 'Title')), $imgUploadField = UploadField::create('ProjectCoverImage', 'Cover Image'), TextareaField::create('ProjectBriefDesc', 'Hover Over Description'), TextField::create('ProjectTitle', 'Title'), HeaderField::create('Project Phases'), $imgPhase1 = UploadField::create('ProjectPhaseImg1', 'Phase 1 Image'), TextareaField::create('ProjectPhaseDesc1', 'Phase 1 Description'), $imgPhase2 = UploadField::create('ProjectPhaseImg2', 'Phase 2 Image'), TextareaField::create('ProjectPhaseDesc2', 'Phase 2 Description'), $imgPhase3 = UploadField::create('ProjectPhaseImg3', 'Phase 3 Image'), TextareaField::create('ProjectPhaseDesc3', 'Phase 3 Description'), $imgPhase4 = UploadField::create('ProjectPhaseImg4', 'Phase 4 Image'), TextareaField::create('ProjectPhaseDesc4', 'Phase 4 Description'), $imgPhase5 = UploadField::create('ProjectPhaseImg5', 'Phase 5 Image'), TextareaField::create('ProjectPhaseDesc5', 'Phase 5 Description'), $imgPhase6 = UploadField::create('ProjectPhaseImg6', 'Phase 6 Image'), TextareaField::create('ProjectPhaseDesc6', 'Phase 6 Description'));
     //create inner GridField for ProjectPhases images
     /*$fields->addFieldToTab('Root.Phases', GridField::create(
           'ProjectPhases',
           'Project Phases',
           $this->ProjectPhases(),
           GridFieldConfig_RecordEditor::create()
       ));*/
     //set image upload getTempFolder
     $imgUploadField->setFolderName('Featured Works Images');
     //validate image upload types
     $imgUploadField->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg'));
     //project phase img 1
     $imgPhase1->setFolderName('Project Phase Images');
     $imgPhase1->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg'));
     //project phase img 2
     $imgPhase2->setFolderName('Project Phase Images');
     $imgPhase2->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg'));
     //project phase img 3
     $imgPhase3->setFolderName('Project Phase Images');
     $imgPhase3->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg'));
     //project phase img 4
     $imgPhase4->setFolderName('Project Phase Images');
     $imgPhase4->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg'));
     //project phase img 5
     $imgPhase5->setFolderName('Project Phase Images');
     $imgPhase5->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg'));
     //project phase img 6
     $imgPhase6->setFolderName('Project Phase Images');
     $imgPhase6->getValidator()->setAllowedExtensions(array('png', 'gif', 'jpg', 'jpeg'));
     //return the fields
     return $fields;
 }
Example #2
0
 public static function useDefault($search_data = null, &$errors, $defaults = null)
 {
     $search = new ProjectSearch($defaults);
     $search->addSearchField('job_no', 'job_no', 'equal');
     $search->addSearchField('status', 'status', 'multi_select');
     $project = new Project();
     $options = array('' => 'All');
     $statuses = $project->getEnumOptions('status');
     $options += $statuses;
     $search->setOptions('status', $options);
     $search->addSearchField('name', 'name_contains', 'contains');
     $search->addSearchField('company', 'company_name', 'begins', null);
     $search->addSearchField('category_id', 'category', 'select', '', 'advanced');
     $cat = new ProjectCategory();
     $cats = $cat->getAll();
     $options = array('' => 'all');
     $options += $cats;
     $search->setOptions('category_id', $options);
     $search->setSearchData($search_data, $errors);
     return $search;
 }
 /**
  * Add default categories to the project
  *
  * @access public
  * @param void
  * @return null
  */
 function add_default_categories()
 {
     if (!ProjectCategory::canAdd(logged_user(), active_project())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('tickets', 'categories'));
     }
     // if
     $default_categories_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('tickets_default_categories', ''));
     if (trim($default_categories_config) == '') {
         $default_categories = array();
     } else {
         $default_categories = explode("\n", $default_categories_config);
     }
     // if
     if (count($default_categories)) {
         $category_names = '';
         $added_categories = array();
         $categories = ProjectCategories::getProjectCategories(active_project());
         foreach ($categories as $category) {
             $added_categories[] = $category->getName();
         }
         try {
             DB::beginWork();
             foreach ($default_categories as $default_category) {
                 $category_name = trim($default_category);
                 if ($category_name == '') {
                     continue;
                 }
                 // if
                 if (in_array($category_name, $added_categories)) {
                     continue;
                 }
                 // if
                 $category = new ProjectCategory();
                 $category->setProjectId(active_project()->getId());
                 $category->setName($category_name);
                 $category->save();
                 ApplicationLogs::createLog($category, active_project(), ApplicationLogs::ACTION_ADD);
                 $category_names .= $category_name . ', ';
                 $added_categories[] = $category_name;
             }
             // foreach
             DB::commit();
             // Error...
         } catch (Exception $e) {
             DB::rollback();
             tpl_assign('error', $e);
         }
         // try
     }
     // if
     flash_success(lang('success add category', $category_names));
     $this->redirectTo('tickets', 'categories');
 }
Example #4
0
<?php

// Set page title and set crumbs to index
set_page_title(lang('ticket categories'));
project_tabbed_navigation(PROJECT_TAB_TICKETS);
project_crumbs(array(array(lang('tickets'), get_url('tickets')), array(lang('ticket categories'))));
if (ProjectCategory::canAdd(logged_user(), active_project())) {
    add_page_action(lang('add ticket category'), get_url('tickets', 'add_category'));
    add_page_action(lang('add default ticket categories'), get_url('tickets', 'add_default_categories'));
}
add_stylesheet_to_page('tickets/tickets.css');
if (isset($categories) && is_array($categories) && count($categories)) {
    ?>
<div id="listing">
<table width="100%" cellpadding="2" border="0">
  <tr>
    <th>Category</th>
    <th>Description</th>
  </tr>
  <?php 
    foreach ($categories as $category) {
        ?>
    <tr>
      <td><a href="<?php 
        echo $category->getViewUrl();
        ?>
"><?php 
        echo $category->getName();
        ?>
</a></td>
      <td><?php 
 /**
  * Add project
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->setTemplate('add_project');
     $this->setLayout('administration');
     if (!logged_user()->canManageProjects()) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $project = new Project();
     $project_data = array_var($_POST, 'project');
     tpl_assign('project', $project);
     tpl_assign('project_data', $project_data);
     // Submitted...
     if (is_array($project_data)) {
         $project->setFromAttributes($project_data);
         $default_folders = array();
         if (plugin_active('files')) {
             $default_folders_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('default_project_folders', ''));
             if (trim($default_folders_config) == '') {
                 $default_folders = array();
             } else {
                 $default_folders = explode("\n", $default_folders_config);
             }
             // if
         }
         // if
         $default_ticket_categories = array();
         if (plugin_active('tickets')) {
             $default_ticket_categories_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('tickets_default_categories', ''));
             if (trim($default_ticket_categories_config) == '') {
                 $default_ticket_categories = array();
             } else {
                 $default_ticket_categories = explode("\n", $default_ticket_categories_config);
             }
             // if
         }
         // if
         try {
             DB::beginWork();
             $project->save();
             $permissions = array_keys(PermissionManager::getPermissionsText());
             $auto_assign_users = owner_company()->getAutoAssignUsers();
             // We are getting the list of auto assign users. If current user is not in the list
             // add it. He's creating the project after all...
             if (is_array($auto_assign_users)) {
                 $auto_assign_logged_user = false;
                 foreach ($auto_assign_users as $user) {
                     if ($user->getId() == logged_user()->getId()) {
                         $auto_assign_logged_user = true;
                     }
                 }
                 // if
                 if (!$auto_assign_logged_user) {
                     $auto_assign_users[] = logged_user();
                 }
             } else {
                 $auto_assign_users[] = logged_user();
             }
             // if
             foreach ($auto_assign_users as $auto_assign_user) {
                 $project_user = new ProjectUser();
                 $project_user->setProjectId($project->getId());
                 $project_user->setUserId($auto_assign_user->getId());
                 $project_user->save();
                 if (is_array($permissions)) {
                     foreach ($permissions as $permission) {
                         $auto_assign_user->setProjectPermission($project, $permission, true);
                     }
                 }
                 // if
             }
             // foreach
             if (count($default_folders)) {
                 $added_folders = array();
                 foreach ($default_folders as $default_folder) {
                     $folder_name = trim($default_folder);
                     if ($folder_name == '') {
                         continue;
                     }
                     // if
                     if (in_array($folder_name, $added_folders)) {
                         continue;
                     }
                     // if
                     $folder = new ProjectFolder();
                     $folder->setProjectId($project->getId());
                     $folder->setName($folder_name);
                     $folder->save();
                     $added_folders[] = $folder_name;
                 }
                 // foreach
             }
             // if
             if (count($default_ticket_categories)) {
                 $added_categories = array();
                 foreach ($default_ticket_categories as $default_ticket_category) {
                     $category_name = trim($default_ticket_category);
                     if ($category_name == '') {
                         continue;
                     }
                     // if
                     if (in_array($category_name, $added_categories)) {
                         continue;
                     }
                     // if
                     $folder = new ProjectCategory();
                     $folder->setProjectId($project->getId());
                     $folder->setName($category_name);
                     $folder->save();
                     $added_categories[] = $category_name;
                 }
                 // foreach
             }
             // if
             ApplicationLogs::createLog($project, null, ApplicationLogs::ACTION_ADD, false, true);
             DB::commit();
             flash_success(lang('success add project', $project->getName()));
             $this->redirectToUrl($project->getPermissionsUrl());
         } catch (Exception $e) {
             tpl_assign('error', $e);
             DB::rollback();
         }
         // try
     }
     // if
 }
 /**
  * Add project
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->setTemplate('add_project');
     $this->setLayout('administration');
     if (!logged_user()->canManageProjects()) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $project = new Project();
     $project_data = array_var($_POST, 'project');
     $page_name = 'project_overview';
     $page_attachments = PageAttachments::getAttachmentsByPageNameAndProject($page_name, $project);
     $redirect_to = urldecode(array_var($_GET, 'redirect_to'));
     tpl_assign('project', $project);
     tpl_assign('project_data', $project_data);
     tpl_assign('page_attachments', $page_attachments);
     tpl_assign('redirect_to', $redirect_to);
     // Submitted...
     if (is_array($project_data)) {
         $project->setFromAttributes($project_data);
         $default_folders = array();
         if (plugin_active('files')) {
             $default_folders_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('default_project_folders', ''));
             if (trim($default_folders_config) == '') {
                 $default_folders = array();
             } else {
                 $default_folders = explode("\n", $default_folders_config);
             }
             // if
         }
         // if
         $default_ticket_categories = array();
         if (plugin_active('tickets')) {
             $default_ticket_categories_config = str_replace(array("\r\n", "\r"), array("\n", "\n"), config_option('tickets_default_categories', ''));
             if (trim($default_ticket_categories_config) == '') {
                 $default_ticket_categories = array();
             } else {
                 $default_ticket_categories = explode("\n", $default_ticket_categories_config);
             }
             // if
         }
         // if
         try {
             DB::beginWork();
             $project->save();
             $permissions = array_keys(PermissionManager::getPermissionsText());
             $auto_assign_users = owner_company()->getAutoAssignUsers();
             // We are getting the list of auto assign users. If current user is not in the list
             // add it. He's creating the project after all...
             if (is_array($auto_assign_users)) {
                 $auto_assign_logged_user = false;
                 foreach ($auto_assign_users as $user) {
                     if ($user->getId() == logged_user()->getId()) {
                         $auto_assign_logged_user = true;
                     }
                 }
                 // if
                 if (!$auto_assign_logged_user) {
                     $auto_assign_users[] = logged_user();
                 }
             } else {
                 $auto_assign_users[] = logged_user();
             }
             // if
             foreach ($auto_assign_users as $auto_assign_user) {
                 $project_user = new ProjectUser();
                 $project_user->setProjectId($project->getId());
                 $project_user->setUserId($auto_assign_user->getId());
                 $project_user->save();
                 if (is_array($permissions)) {
                     foreach ($permissions as $permission) {
                         $auto_assign_user->setProjectPermission($project, $permission, true);
                     }
                 }
                 // if
             }
             // foreach
             if (count($default_folders)) {
                 $added_folders = array();
                 foreach ($default_folders as $default_folder) {
                     $folder_name = trim($default_folder);
                     if ($folder_name == '') {
                         continue;
                     }
                     // if
                     if (in_array($folder_name, $added_folders)) {
                         continue;
                     }
                     // if
                     $folder = new ProjectFolder();
                     $folder->setProjectId($project->getId());
                     $folder->setName($folder_name);
                     $folder->save();
                     $added_folders[] = $folder_name;
                 }
                 // foreach
             }
             // if
             if (count($default_ticket_categories)) {
                 $added_categories = array();
                 foreach ($default_ticket_categories as $default_ticket_category) {
                     $category_name = trim($default_ticket_category);
                     if ($category_name == '') {
                         continue;
                     }
                     // if
                     if (in_array($category_name, $added_categories)) {
                         continue;
                     }
                     // if
                     $folder = new ProjectCategory();
                     $folder->setProjectId($project->getId());
                     $folder->setName($category_name);
                     $folder->save();
                     $added_categories[] = $category_name;
                 }
                 // foreach
             }
             // if
             $efqm_project = isset($project_data['efqm_project']) ? $project_data['efqm_project'] == '1' : false;
             if ($efqm_project) {
                 // insert 9 milestones with task lists
                 $efqm_template = array('efqm leadership' => array('a', 'b', 'c', 'd', 'e'), 'efqm strategy' => array('a', 'b', 'c', 'd'), 'efqm people' => array('a', 'b', 'c', 'd', 'e'), 'efqm partnership and resources' => array('a', 'b', 'c', 'd', 'e'), 'efqm processes products services' => array('a', 'b', 'c', 'd', 'e'), 'efqm customer results' => array('a', 'b'), 'efqm people results' => array('a', 'b'), 'efqm society results' => array('a', 'b'), 'efqm key results' => array('a', 'b'));
                 foreach ($efqm_template as $criteria => $subcriteria) {
                     $milestone = new ProjectMilestone();
                     $milestone->setProjectId($project->getId());
                     $milestone->setName(lang($criteria));
                     $milestone->setGoal(config_option('initial goal', 80));
                     $milestone->setDueDate(DateTimeValueLib::now());
                     $offset_in_days = config_option('due date offset', 90);
                     $milestone->getDueDate()->advance(60 * 60 * 24 * $offset_in_days);
                     $milestone->save();
                     foreach ($subcriteria as $subname) {
                         $task_list = new ProjectTaskList();
                         $task_list->setMilestoneId($milestone->getId());
                         $task_list->setProjectId($project->getId());
                         $task_list->setName(lang($criteria) . ' ' . $subname);
                         $task_list->setDueDate($milestone->getDueDate());
                         $task_list->setScore(config_option('initial score', 50));
                         $task_list->save();
                     }
                 }
             }
             ApplicationLogs::createLog($project, null, ApplicationLogs::ACTION_ADD, false, true);
             DB::commit();
             flash_success(lang('success add project', $project->getName()));
             $this->redirectToUrl($project->getPermissionsUrl());
         } catch (Exception $e) {
             tpl_assign('error', $e);
             DB::rollback();
         }
         // try
     }
     // if
 }