Kimai_Database_Mysql::project_create PHP Method

project_create() public method

Adds a new project
Author: th
public project_create ( array $data ) : integer
$data array name, comment and other data of the new project
return integer the ID of the new project, false on failure
    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;
    }
Kimai_Database_Mysql