public function project_create($data)
{
$data = $this->clean_data($data);
$values['name'] = MySQL::SQLValue($data['name']);
$values['comment'] = MySQL::SQLValue($data['comment']);
$values['budget'] = MySQL::SQLValue($data['budget'], MySQL::SQLVALUE_NUMBER);
$values['effort'] = MySQL::SQLValue($data['effort'], MySQL::SQLVALUE_NUMBER);
$values['approved'] = MySQL::SQLValue($data['approved'], MySQL::SQLVALUE_NUMBER);
$values['customerID'] = MySQL::SQLValue($data['customerID'], MySQL::SQLVALUE_NUMBER);
$values['visible'] = MySQL::SQLValue($data['visible'], MySQL::SQLVALUE_NUMBER);
$values['internal'] = MySQL::SQLValue($data['internal'], MySQL::SQLVALUE_NUMBER);
$values['filter'] = MySQL::SQLValue($data['filter'], MySQL::SQLVALUE_NUMBER);
$table = $this->kga['server_prefix'] . "projects";
$result = $this->conn->InsertRow($table, $values);
if (!$result) {
$this->logLastError('project_create');
return false;
}
$projectID = $this->conn->GetLastInsertID();
if (isset($data['defaultRate'])) {
if (is_numeric($data['defaultRate'])) {
$this->save_rate(null, $projectID, null, $data['defaultRate']);
} else {
$this->remove_rate(null, $projectID, null);
}
}
if (isset($data['myRate'])) {
if (is_numeric($data['myRate'])) {
$this->save_rate($this->kga['user']['userID'], $projectID, null, $data['myRate']);
} else {
$this->remove_rate($this->kga['user']['userID'], $projectID, null);
}
}
if (isset($data['fixedRate'])) {
if (is_numeric($data['fixedRate'])) {
$this->save_fixed_rate($projectID, null, $data['fixedRate']);
} else {
$this->remove_fixed_rate($projectID, null);
}
}
return $projectID;
}