* http://www.gnu.org/copyleft/gpl.html * */ require_once 'includes/common.php'; require_once 'includes/SI_Project.php'; require_once 'includes/SI_Company.php'; require_once 'includes/SI_Task.php'; checkLogin(); $company = new SI_Company(); $project = new SI_Project(); $title = "Create Project"; if ($_POST['save']) { $project->owner_id = $loggedin_user->id; $_POST['due_ts'] = getTSFromInput($_POST['due_ts']); $project->updateFromAssocArray($_POST); if ($project->add()) { foreach ($_POST['tasks'] as $task_data) { if (!empty($task_data['name'])) { $task = new SI_Task(); $task->name = $task_data['name']; $task->billable = 'D'; $task->task_status_id = $task_data['status']; $task->task_priority_id = $task_data['priority']; $task->project_id = $project->id; if (!$task->add()) { $error_msg .= "Error adding task {$task_data['name']} to project\n"; debug_message($task->getLastError()); } } } if (empty($error_msg)) {
require_once('includes/SI_ProjectPriority.php'); require_once('includes/SI_SalesCommissionType.php'); $title = ''; $project = new SI_Project(); if($_REQUEST['mode'] == 'add'){ $title = "Add Project"; $project->owner_id = $loggedin_user->id; $project->due_ts = ''; if(isset($_REQUEST['company_id'])) $project->company_id = $_REQUEST['company_id']; if($_POST['save']){ $_POST['due_ts'] = getTSFromInput($_POST['due_ts']); $project->updateFromAssocArray($_POST); if($project->add() !== false){ goBack(); }else{ $error_msg .= "Error adding Project!\n"; debug_message($project->getLastError()); } } }else if($_REQUEST['mode'] == 'edit'){ $title = "Edit Project"; if(empty($_REQUEST['id'])){ $error_msg .= "Error: No ID specified!\n"; }else{ if(!$project->get($_REQUEST['id'])){ $error_msg .= "Could not retreive project information!\n"; debug_message($project->getLastError()); }