Example #1
0
// prepare (and translate) the module name ready for the suffix
if ($del) {
    $project_id = dPgetParam($_POST, 'project_id', 0);
    $canDelete = $obj->canDelete($msg, $project_id);
    if (!$canDelete) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    }
    if ($msg = $obj->delete()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
        $AppUI->redirect();
    } else {
        $AppUI->setMsg("Project deleted", UI_MSG_ALERT);
        $AppUI->redirect("m=projects");
    }
} else {
    if ($msg = $obj->store()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        $isNotNew = @$_POST['project_id'];
        if ($importTask_projectId = dPgetParam($_POST, 'import_tasks_from', '0')) {
            $obj->importTasks($importTask_projectId);
        }
        $AppUI->setMsg($isNotNew ? 'Project updated' : 'Project inserted', UI_MSG_OK, true);
        $custom_fields = new CustomFields($m, 'addedit', $obj->project_id, "edit");
        $custom_fields->bind($_POST);
        $sql = $custom_fields->store($obj->project_id);
        // Store Custom Fields
    }
    $AppUI->redirect();
}
Example #2
0
/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$del = (int) w2PgetParam($_POST, 'del', 0);
$obj = new CProject();
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
if (!w2PgetParam($_POST, 'project_departments', 0)) {
    $obj->project_departments = implode(',', w2PgetParam($_POST, 'dept_ids', array()));
}
$action = $del ? 'deleted' : 'stored';
$result = $del ? $obj->delete() : $obj->store();
$redirect = $del ? 'm=projects' : 'm=projects&a=view&project_id=' . $obj->project_id;
$notify_owner = w2PgetParam($_POST, 'email_project_owner_box', 'off');
$notify_contacts = w2PgetParam($_POST, 'email_project_contacts_box', 'off');
$notfiyTrigger = $del ? 1 : $obj->project_id;
$importTask_projectId = (int) w2PgetParam($_POST, 'import_tasks_from', '0');
if (is_array($result)) {
    $AppUI->setMsg($result, UI_MSG_ERROR);
    $AppUI->holdObject($obj);
    $AppUI->redirect('m=projects&a=addedit');
}
if ($result) {
    if (!$del) {
        $billingCategory = w2PgetSysVal('BudgetCategory');
        $budgets = array();
        foreach ($billingCategory as $id => $category) {
Example #3
0
 /**
  * Put Request Handler
  *
  * This method is called when a request is a PUT
  *
  * @return array
  */
 public function executePut()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     // Attempt to login as user, a little bit of a hack as we currently
     // require the $_POST['login'] var to be set as well as a global AppUI
     $AppUI = new CAppUI();
     $GLOBALS['AppUI'] = $AppUI;
     $_POST['login'] = '******';
     if (!$AppUI->login($username, $password)) {
         throw new Frapi_Error('INVALID_LOGIN');
     }
     $post_data = array('project_id' => 0, 'project_creator' => $AppUI->user_id, 'project_contacts' => $this->getParam('project_contacts'), 'project_name' => $this->getParam('project_name'), 'project_parent' => $this->getParam('project_parent'), 'project_owner' => $this->getParam('project_owner'), 'project_company' => $this->getParam('project_company'), 'project_location' => $this->getParam('project_location'), 'project_start_date' => $this->getParam('project_start_date'), 'project_end_date' => $this->getParam('project_end_date'), 'project_target_budget' => $this->getParam('project_target_budget'), 'project_actual_budget' => $this->getParam('project_actual_budget'), 'project_url' => $this->getParam('project_url'), 'project_demo_url' => $this->getParam('project_demo_url'), 'project_priority' => $this->getParam('project_priority'), 'project_short_name' => $this->getParam('project_short_name'), 'project_color_identifier' => $this->getParam('project_color_identifier'), 'project_type' => $this->getParam('project_type'), 'project_status' => $this->getParam('project_status'), 'project_description' => $this->getParam('project_description'), 'project_departments' => $this->getParam('project_departments', self::TYPE_ARRAY), 'project_active' => $this->getParam('project_active'));
     $project = new CProject();
     $project->bind($post_data);
     $error_array = $project->store($AppUI);
     // Return all the validation messages
     if ($error_array !== true) {
         $error_message = '';
         foreach ($error_array as $error) {
             $error_message .= $error . '. ';
         }
         throw new Frapi_Error('SAVE_ERROR', $error_message);
     }
     $project = (array) $project;
     $pd = CProject::getDepartments($AppUI, $project['project_id']);
     $project_departments = array();
     foreach ($pd as $key => $value) {
         $project_departments[] = $value['dept_id'];
     }
     $project['project_departments'] = $project_departments;
     // Remove the data that is not for display
     unset($project['_tbl_prefix'], $project['_tbl'], $project['_tbl_key'], $project['_error'], $project['_query'], $project['_tbl_module']);
     $this->data['project'] = $project;
     $this->data['success'] = true;
     return new Frapi_Response(array('code' => 201, 'data' => $this->data));
 }
Example #4
0
/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$del = (int) w2PgetParam($_POST, 'del', 0);
$obj = new CProject();
if (!$obj->bind($_POST)) {
    $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
    $AppUI->redirect();
}
if (!w2PgetParam($_POST, 'project_departments', 0)) {
    $obj->project_departments = implode(',', w2PgetParam($_POST, 'dept_ids', array()));
}
$action = $del ? 'deleted' : 'stored';
$result = $del ? $obj->delete($AppUI) : $obj->store($AppUI);
$notify_owner = $_POST['email_project_owner_box'] ? 1 : 0;
$notify_contacts = $_POST['email_project_contacts_box'] ? 1 : 0;
$notfiyTrigger = $del ? 1 : $obj->project_id;
$importTask_projectId = (int) w2PgetParam($_POST, 'import_tasks_from', '0');
if (is_array($result)) {
    $AppUI->setMsg($result, UI_MSG_ERROR);
    $AppUI->holdObject($obj);
    $AppUI->redirect('m=projects&a=addedit');
}
if ($result) {
    if ($importTask_projectId) {
        $obj->importTasks($importTask_projectId);
    }
    if ($notify_owner) {
        if ($msg = $obj->notifyOwner($notfiyTrigger)) {
<?php

if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$project_ids = w2PgetParam($_POST, 'project_ids', array());
// Note: This is an array
$status_id = (int) w2PgetParam($_POST, 'project_status', 0);
foreach ($project_ids as $project_id) {
    if (0 == (int) $project_id) {
        continue;
    }
    $project = new CProject();
    $project->load($project_id);
    $project->project_status = $status_id;
    foreach ($project->getContactList() as $contact_data) {
        $project->project_contacts[] = $contact_data['contact_id'];
    }
    foreach ($project->getDepartmentList() as $department_data) {
        $project->project_departments[] = $department_data['dept_id'];
    }
    $project->store();
}
$AppUI->redirect('m=projects');
Example #6
0
/* $Id: index.php 1717 2011-03-08 06:21:34Z caseydk $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/tags/version2.4/modules/projects/index.php $ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
$AppUI->savePlace();
$structprojs = getProjects();
// Let's update project status!
if (isset($_GET['update_project_status']) && isset($_GET['project_status']) && isset($_GET['project_id'])) {
    $projects_id = w2PgetParam($_GET, 'project_id', array());
    // This must be an array
    $statusId = w2PgetParam($_GET, 'project_status', 0);
    $project = new CProject();
    foreach ($projects_id as $project_id) {
        $project->load($project_id);
        $project->project_status = $statusId;
        $project->store($AppUI);
    }
}
if (isset($_POST['projsearchtext'])) {
    $AppUI->setState('projsearchtext', w2PformSafe($_POST['projsearchtext'], true));
}
$search_text = $AppUI->getState('projsearchtext') !== null ? $AppUI->getState('projsearchtext') : '';
$projectDesigner = $AppUI->getState('ProjIdxProjectDesigner') !== null ? $AppUI->getState('ProjIdxProjectDesigner') : 0;
$tab = $AppUI->processIntState('ProjIdxTab', $_GET, 'tab', 1);
$currentTabId = $tab;
$active = intval(!$AppUI->getState('ProjIdxTab'));
$oCompany = new CCompany();
$allowedCompanies = $oCompany->getAllowedRecords($AppUI->user_id, 'company_id,company_name');
if (isset($_POST['company_id'])) {
    $AppUI->setState('ProjIdxCompany', intval($_POST['company_id']));
}
Example #7
0
 /**
  * @deprecated
  */
 public static function updateTaskCount($projectId, $taskCount)
 {
     trigger_error("CProject::updateTaskCount has been deprecated in v2.3 and will be removed by v4.0. Please use CProject::updateTaskCache instead.", E_USER_NOTICE);
     if ((int) $projectId) {
         $project = new CProject();
         $project->load($projectId);
         $project->project_task_count = $taskCount;
         $project->store();
         self::updatePercentComplete($projectId);
     }
 }
 protected function _processProject(CAppUI $AppUI, $company_id, $projectInfo)
 {
     $projectName = w2PgetParam($projectInfo, 'new_project', 'New Project');
     $projectStartDate = w2PgetParam($projectInfo, 'project_start_date', 'New Project');
     $projectEndDate = w2PgetParam($projectInfo, 'project_end_date', 'New Project');
     $projectOwner = w2PgetParam($projectInfo, 'project_owner', $AppUI->user_id);
     $projectStatus = w2PgetParam($projectInfo, 'project_status', 0);
     $project = new CProject();
     $project->project_name = $projectName;
     $project->project_short_name = substr($projectName, 0, 8);
     $project->project_company = $company_id;
     $project->project_start_date = $projectStartDate;
     $project->project_end_date = $projectEndDate;
     $project->project_owner = $projectOwner;
     $project->project_creator = $AppUI->user_id;
     $project->project_status = $projectStatus;
     $project->project_active = 1;
     $project->project_priority = '0';
     $project->project_type = '0';
     $project->project_color_identifier = 'FFFFFF';
     $project->project_parent = null;
     $project->project_original_parent = null;
     $result = $project->store($AppUI);
     return is_array($result) ? $result : $project->project_id;
 }