@@ -140,7 +140,7 @@ class ProjectsController | |||
{ | |||
$db = $this->container->get('db'); | |||
$query = $db->prepare(' | |||
SELECT P.id, P.name, P.description, P.team_id, P.city, P.country, T.name as team_name, P.client_id, C.name as client_name, C.btw_nr, C.address | |||
SELECT P.id, P.name, P.description, P.team_id, P.city, P.country, P.cost_per_hour, T.name as team_name, P.client_id, C.name as client_name, C.btw_nr, C.address | |||
FROM project P | |||
LEFT JOIN team T | |||
ON P.team_id = T.id | |||
@@ -180,19 +180,20 @@ class ProjectsController | |||
$db = $this->container->get('db'); | |||
if (!$projectId) { | |||
$query = $db->prepare(' | |||
INSERT INTO project (name, description) | |||
values (:name, :description) | |||
INSERT INTO project (name, description, cost_per_hour) | |||
values (:name, :description, :cost_per_hour) | |||
'); | |||
} else { | |||
$query = $db->prepare(' | |||
UPDATE project | |||
SET name = :name, description = :description | |||
SET name = :name, description = :description, cost_per_hour = :cost_per_hour | |||
WHERE id = :id | |||
'); | |||
$query->bindValue(':id', $projectId); | |||
} | |||
$query->bindValue(':name', $parsedBody['name']); | |||
$query->bindValue(':description', $parsedBody['description']); | |||
$query->bindValue(':cost_per_hour', $parsedBody['cost_per_hour']); | |||
if ($query->execute()) { | |||
$response->getBody()->write($projectId ?: strval($db->lastInsertRowID())); |
@@ -18,6 +18,12 @@ | |||
<FormulateInput type="hidden" name="team_id" :value="project.team_id" /> | |||
<FormulateInput | |||
type="text" | |||
name="cost_per_hour" | |||
:value="project.cost_per_hour" | |||
label="Cost per hour" | |||
/> | |||
<FormulateInput | |||
type="text" | |||
name="team_name" | |||
:value="project.team_name" | |||
label="Team" | |||
@@ -37,10 +43,6 @@ | |||
/> | |||
<FormulateInput type="submit" value="save" label="Save" /> | |||
</FormulateForm> | |||
<n-link :to="'/factuur/new?project=' + project.id"> | |||
factureer | |||
</n-link> | |||
</div> | |||
<Loader /> |
@@ -62,10 +62,13 @@ | |||
<td>{{ Taskitem.name }}</td> | |||
<td>{{ Taskitem.description }}</td> | |||
<td>{{ Taskitem.time }}</td> | |||
<td>50</td> | |||
<td>{{ project.cost_per_hour }}</td> | |||
<td>20%</td> | |||
<td> | |||
{{ ((50 * Taskitem.time) / 100) * 20 + 50 * Taskitem.time }} | |||
{{ | |||
((project.cost_per_hour * Taskitem.time) / 100) * 20 + | |||
project.cost_per_hour * Taskitem.time | |||
}} | |||
</td> | |||
</tr> | |||
</tbody> | |||
@@ -142,7 +145,9 @@ export default { | |||
console.log(this.mergeStates); | |||
this.mergeStates.forEach((state) => { | |||
state.tasks.forEach((Taskitem) => { | |||
this.Total += ((50 * Taskitem.time) / 100) * 20 + 50 * Taskitem.time; | |||
this.Total += | |||
((this.project.cost_per_hour * Taskitem.time) / 100) * 20 + | |||
this.project.cost_per_hour * Taskitem.time; | |||
}); | |||
}); | |||
console.log(this.Total); |