public function createform()
 {
     if (isset($_POST) && !empty($_POST)) {
         $proj_name = $_POST['proj_name'];
         if (!empty($_POST['proj_name'])) {
             $project_exist = Project::findByattr($proj_name);
             if ($project_exist) {
                 $msg = 0;
                 $this->redirecturl('pages', 'home', '0');
             } else {
                 $project = Project::insert($proj_name);
                 if ($project == true) {
                     $msg = 1;
                     $this->redirecturl('pages', 'home', '1');
                 }
                 //                else{
                 //                     $_SESSION['success']=0;
                 //                 require_once('views/pages/home.php');
                 //                }
             }
         }
     } else {
         $msg = 0;
         $this->redirecturl('pages', 'home', '0');
     }
 }
Example #2
0
 public function run()
 {
     $controller = $this->getController();
     if (isset(Yii::app()->session["userId"])) {
         try {
             $res = Project::insert($_POST, Yii::app()->session["userId"]);
         } catch (CTKException $e) {
             $res = array("result" => false, "msg" => $e->getMessage());
         }
         Rest::json($res);
     } else {
         $res = array("result" => false, "msg" => "You must be connected to create a project");
     }
 }
Example #3
0
include_once APP_INC_PATH . "class.project.php";
include_once APP_INC_PATH . "class.user.php";
include_once APP_INC_PATH . "class.status.php";
include_once APP_INC_PATH . "class.workflow.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "projects");
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
    if ($role_id == User::getRoleID('administrator')) {
        $tpl->assign("show_setup_links", true);
    }
    if (@$HTTP_POST_VARS["cat"] == "new") {
        $tpl->assign("result", Project::insert());
    } elseif (@$HTTP_POST_VARS["cat"] == "update") {
        $tpl->assign("result", Project::update());
    } elseif (@$HTTP_POST_VARS["cat"] == "delete") {
        Project::remove();
    }
    $tpl->assign("active_projects", Project::getAssocList(Auth::getUserID(), true));
    if (@$HTTP_GET_VARS["cat"] == "edit") {
        $tpl->assign("info", Project::getDetails($HTTP_GET_VARS["id"]));
    }
    $tpl->assign("list", Project::getList());
    $tpl->assign("user_options", User::getActiveAssocList(false, NULL, false, false, true));
    $tpl->assign("status_options", Status::getAssocList());
    $tpl->assign("customer_backends", Customer::getBackendList());
    $tpl->assign("workflow_backends", Workflow::getBackendList());
} else {
Example #4
0
/**
* Submit changes to notes on a person
*
* @ingroup pages
*/
function taskNoteOnPersonEditSubmit()
{
    global $PH;
    global $auth;
    global $g_user_profile_names;
    ### cancel? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('personView', array('person' => getOnePassedId('person_id')));
        }
        exit;
    }
    ### temporary object or from database? ###
    $tsk_id = getOnePassedId('tsk', '', true, 'invalid id');
    if ($tsk_id == 0) {
        $task = new Task(array('id' => 0));
    }
    ## eventually needed later when note is a subcategory of task
    /*else {
          if(!$task= Task::getVisiblebyId($tsk_id)) {
              $PH->abortWarning(__("ERROR: could not get task"), ERROR_NOTE);
              return;
          }
      }*/
    ## other parameter ##
    $person_id = getOnePassedId('person_id');
    $prj_id = get('project');
    $prj_new = get('new_project');
    $prj_name = get('new_project_name');
    $assignement1 = get('task_assignement1');
    $assignement2 = get('task_assignement2');
    $also_assignement = get('task_also_assign');
    ### pub level ###
    if ($pub_level = get('task_pub_level')) {
        if ($task->id) {
            if ($pub_level > $task->getValidUserSetPublicLevels()) {
                $PH->abortWarning('invalid data', ERROR_RIGHTS);
            }
        }
        #else {
        #    #@@@ check for person create rights
        #}
        $task->pub_level = $pub_level;
    }
    ## prio ##
    if ($prio = get('task_prio')) {
        $task->prio = $prio;
    }
    ## status ##
    if (!$task->id) {
        $task->status = STATUS_NEW;
    }
    # retrieve all possible values from post-data (with field->view_in_forms == true)
    # NOTE:
    # - this could be an security-issue.
    # @@@ TODO: as some kind of form-edit-behaviour to field-definition
    foreach ($task->fields as $f) {
        $name = $f->name;
        $f->parseForm($task);
    }
    ### validate ###
    $is_ok = true;
    ## no project ##
    if ($prj_id <= 0) {
        if (!isset($prj_new) || !isset($prj_name)) {
            new FeedbackWarning(__("Note requires project"));
            ## and no assignement ##
            if (!isset($assignement1) && !isset($assignement2) && $also_assignement == -1) {
                new FeedbackWarning(__("Note requires assigned person(s)"));
            }
            $is_ok = false;
        }
    }
    ## if project but no assignement ##
    if (!isset($assignement1) && !isset($assignement2) && $also_assignement == -1) {
        $assignement1 = $auth->cur_user->id;
    }
    if (!$is_ok) {
        $PH->show('taskNoteOnPersonEdit', array('tsk' => $task->id, 'person' => $person_id), $task);
        exit;
    }
    ## new project
    if (isset($prj_new) && isset($prj_name)) {
        $pperson = Person::getById($person_id);
        if ($companies = $pperson->getCompanies()) {
            $company_id = $companies[0]->id;
        } else {
            $company_id = 0;
        }
        $new_project = new Project(array('name' => $prj_name, 'company' => $company_id, 'status' => STATUS_NEW, 'prio' => PRIO_NORMAL, 'pub_level' => PUB_LEVEL_OPEN));
        $new_project->insert();
        $prj_id = $new_project->id;
        ## get project ##
        if (!($project = Project::getById($prj_id))) {
            $PH->abortWarning(__("ERROR: could not get project"), ERROR_NOTE);
        }
    } else {
        ## get project ##
        if (!($project = Project::getById($prj_id))) {
            $PH->abortWarning(__("ERROR: could not get project"), ERROR_NOTE);
        }
    }
    ## set project of task ##
    if (!$task->id) {
        $task->project = $project->id;
    }
    ## assigne people to task##
    $new_task_assignments = array();
    $count = 0;
    if (!$task->id) {
        if (isset($assignement1)) {
            $person = Person::getById($assignement1);
            $new_assignment1 = new TaskPerson(array('person' => $assignement1, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $person->name), 'project' => $project->id));
            $new_task_assignments[$count] = $new_assignment1;
            $count++;
        }
        if (isset($assignement2)) {
            $person = Person::getById($assignement2);
            $new_assignment2 = new TaskPerson(array('person' => $assignement2, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $person->name), 'project' => $project->id));
            $new_task_assignments[$count] = $new_assignment2;
            $count++;
        }
        if ($also_assignement != -1) {
            $person = Person::getById($also_assignement);
            $new_assignment_also = new TaskPerson(array('person' => $also_assignement, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $person->name), 'project' => $project->id));
            $new_task_assignments[$count] = $new_assignment_also;
            $count++;
        }
    }
    ## eventually needed later when note is a subcategory of task
    /*else {
          # ToDo: check if people are assigned
      }*/
    ## assigne person to project ##
    $team = array();
    $new_project_assignments = array();
    $count = 0;
    if (!$task->id) {
        $projperson = $project->getPeople(false);
        foreach ($projperson as $projp) {
            $team[$projp->id] = $projp->name;
        }
        if (isset($assignement1)) {
            if (!isset($team[$assignement1])) {
                $person = Person::getById($assignement1);
                $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1;
                $pp_new1 = new ProjectPerson(array('person' => $person->id, 'project' => $project->id, 'name' => $g_user_profile_names[$person->profile], 'adjust_effort_style' => $effort_style));
                $new_project_assignments[$count] = $pp_new1;
                $count++;
            }
        }
        if (isset($assignement2)) {
            if (!isset($team[$assignement2])) {
                $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1;
                $person = Person::getById($assignement2);
                $pp_new2 = new ProjectPerson(array('person' => $person->id, 'project' => $project->id, 'name' => $g_user_profile_names[$person->profile], 'adjust_effort_style' => $effort_style));
                $new_project_assignments[$count] = $pp_new2;
                $count++;
            }
        }
        if ($also_assignement != -1) {
            if (!isset($team[$also_assignement])) {
                $person = Person::getById($also_assignement);
                $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1;
                $pp_new_also = new ProjectPerson(array('person' => $person->id, 'project' => $project->id, 'name' => $g_user_profile_names[$person->profile], 'adjust_effort_style' => $effort_style));
                $new_project_assignments[$count] = $pp_new_also;
                $count++;
            }
        }
    }
    ## eventually needed later when note is a subcategory of task
    /*else{
          # ToDo: check if people are assigned
      }*/
    ## Insert ##
    if ($task->id == 0) {
        $task->insert();
        ### write task-assigments ###
        foreach ($new_task_assignments as $nta) {
            $nta->task = $task->id;
            $nta->insert();
        }
        ### write project-assigments ###
        foreach ($new_project_assignments as $npa) {
            $npa->insert();
        }
        new FeedbackMessage(sprintf(__("Created task %s with ID %s"), $task->getLink(false), $task->id));
    }
    ## eventually needed later when note is a subcategory of task
    /*
    else{
    }
    */
    ### book effort ###
    $book_effort = get('book_effort');
    if ($book_effort) {
        $as_duration = 0;
        if ($pperson = $project->getProjectPeople()) {
            foreach ($pperson as $pp) {
                if ($pp->project == $project->id && $pp->person == $auth->cur_user->id) {
                    if ($pp->adjust_effort_style == 1) {
                        $as_duration = 0;
                    } else {
                        $as_duration = 1;
                    }
                }
            }
        } else {
            $as_duration = 0;
        }
        if (get('creation_time')) {
            $start_time = get('creation_time');
        } else {
            $start_time = '';
        }
        ### build new object ###
        $newEffort = new Effort(array('id' => 0, 'name' => '', 'project' => $project->id, 'task' => $task->id, 'person' => $auth->cur_user->id, 'as_duration' => $as_duration, 'time_start' => $start_time));
        $PH->show('effortEdit', array('effort' => $newEffort->id), $newEffort);
        exit;
    }
    ### display personList ####
    if (!$PH->showFromPage()) {
        $PH->show('personList', array());
    }
}
Example #5
0
 * For the full copyright and license information,
 * please see the COPYING and AUTHORS files
 * that were distributed with this source code.
 */
require_once __DIR__ . '/../../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('manage/projects.tpl.html');
Auth::checkAuthentication();
$role_id = Auth::getCurrentRole();
if ($role_id < User::ROLE_MANAGER) {
    Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR);
    $tpl->displayTemplate();
    exit;
}
if (@$_POST['cat'] == 'new') {
    Misc::mapMessages(Project::insert(), array(1 => array(ev_gettext('Thank you, the project was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new project.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this new project.'), Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'update') {
    Misc::mapMessages(Project::update(), array(1 => array(ev_gettext('Thank you, the project was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the project information.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this project.'), Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'delete') {
    Misc::mapMessages(Project::remove(), array(1 => array(ev_gettext('Thank you, the project was deleted successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to delete the project.'), Misc::MSG_ERROR)));
}
$tpl->assign('active_projects', Project::getAssocList(Auth::getUserID(), true));
if (@$_GET['cat'] == 'edit') {
    $tpl->assign('info', Project::getDetails($_GET['id']));
}
$tpl->assign('list', Project::getList());
$tpl->assign('user_options', User::getActiveAssocList());
$tpl->assign('status_options', Status::getAssocList());
$tpl->assign('customer_backends', CRM::getBackendList());
$tpl->assign('workflow_backends', Workflow::getBackendList());
$tpl->displayTemplate();