<?php

session_start();
require_once 'classes/crud.php';
if (!empty($_POST)) {
    $project_name = $_POST['project_name'];
    $idworkerProject = $_SESSION['workerId'];
    $idclient = $_POST['idclient'];
    $dbObject = new crud('projects');
    $projectQuery = "INSERT INTO projects VALUES ('', '{$project_name}' , '{$idworkerProject}', '1', '{$idclient}')";
    if ($dbObject->query($projectQuery)) {
        //Вставка записи проекта
        $idproject = $dbObject->getMaxId('projects');
        $names = $_POST['name'];
        $summaries = $_POST['summary'];
        $startdates = $_POST['startdate'];
        $finishdates = $_POST['finishdate'];
        $idworkers = $_POST['worker'];
        $descriptions = $_POST['description'];
        $query = "INSERT INTO tasks VALUES ";
        for ($i = 0; $i < count($_POST['name']); $i++) {
            $set .= " ( {$names[$i]}, {$summaries[$i]}, {$startdates[$i]}, {$finishdates[$i]}, {$idproject}, {$idworkers[$i]}, {$descriptions[$i]} ),";
        }
        $set = substr($set, 0, -1);
        $query = $query . $set;
        if ($dbObject->query($query)) {
            echo "Создание проекта заверешно";
        } else {
            echo "Возникли ошибки при добавлении задач";
        }
    } else {
示例#2
0
<?php

session_start();
$workerId = $_SESSION['workerId'];
if (!empty($_POST['idTask'])) {
    $idTask = $_POST['idTask'];
    require_once 'classes/crud.php';
    $dbObject = new crud('tasks');
    $query = "UPDATE tasks SET opened = 0 WHERE id = '{$idTask}' ";
    $dbObject->query($query);
}
<?php

session_start();
$workerId = $_SESSION['workerId'];
if (!empty($_POST['commentText']) && !empty($_POST['idTask']) && !empty($_POST['commentText'])) {
    $commentText = $_POST['commentText'];
    $idTask = $_POST['idTask'];
    $commentText = $_POST['commentText'];
    require_once 'classes/crud.php';
    $dbObject = new crud('tasks');
    $query = "INSERT INTO comments VALUES ('', '{$workerId}', '{$idTask}', '{$commentText}')";
    if ($dbObject->query($query)) {
        echo true;
    } else {
        echo false;
    }
}