<?php
include_once "global.php";

$pageTitle = 'Add Project - ';
include_once 'header.php';
?>

<!--breadcrumb-->
<div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
    <div class="breadcrumb-title pe-3">Projects Management</div>
    <div class="ps-3">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb mb-0 p-0">
                <li class="breadcrumb-item"><a href="javascript:;"></a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Add Project</li>
            </ol>
        </nav>
    </div>
</div>
<!--end breadcrumb-->
<div class="card">
    <div class="card-body p-4">
        <h5 class="mb-4">Add Project</h5>
        <form id="projectAddForm" class="row g-3" method="post" enctype="multipart/form-data">
            <div class="col-md-6">
                <label for="projTitle" class="form-label">Title <span>*</span></label>
                <input type="text" class="form-control" id="projTitle" name="projTitle" required>
            </div>
            <div class="col-md-6">
                <label for="projClientId" class="form-label">Client Name <span>*</span></label>
                <select id="projClientId" name="projClientId" class="form-select" required>
                    <option value="" disabled selected>Select...</option>
                    <?php
                    $clients = $productClass->AllClientsArray();
                    foreach ($clients as $client) {
                        $clientId = $client["acc_id"];
                        $name = $client["acc_name"];
                        echo "<option value='$clientId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projCompany" class="form-label">Company Name <span>*</span></label>
                <input type="text" class="form-control" id="projCompany" name="projCompany" required>
            </div>
            <div class="col-md-6">
                <label for="projCountry" class="form-label">Country <span>*</span></label>
                <select id="projCountry" name="projCountry" class="single-select-field" data-placeholder="Select a country" required>
                    <option value="" disabled selected>Select...</option>
                    <?php echo $functions->countrySelectOption(); ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projDomain" class="form-label">Domain <span>*</span></label>
                <input type="text" class="form-control" id="projDomain" name="projDomain" required>
            </div>
            <div class="col-md-6">
                <label for="projTypeId" class="form-label">Type <span>*</span></label>
                <select id="projTypeId" name="projTypeId" class="form-select" required>
                    <option value="" disabled selected>Select...</option>
                    <?php
                    $projectTypes = $productClass->getProjectTypes();
                    foreach ($projectTypes as $projectType) {
                        $typeId = $projectType["id"];
                        $name = $projectType["name"];
                        echo "<option value='$typeId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projCategoryId" class="form-label">Category <span>*</span></label>
                <select id="projCategoryId" name="projCategoryId" class="form-select" required>
                    <option value="" disabled selected>Select...</option>
                    <?php
                    $projectCategories = $productClass->getProjectCategories();
                    foreach ($projectCategories as $projectCategory) {
                        $categoryId = $projectCategory["id"];
                        $name = $projectCategory["category"];
                        echo "<option value='$categoryId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projStatusId" class="form-label">Status <span>*</span></label>
                <select id="projStatusId" name="projStatusId" class="form-select" required>
                    <option value="" disabled selected>Select...</option>
                    <?php
                    $projectStatuses = $productClass->getProjectStatuses();
                    foreach ($projectStatuses as $projectStatus) {
                        $statusId = $projectStatus["id"];
                        $name = $projectStatus["name"];
                        echo "<option value='$statusId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-12">
                <label for="projDesc" class="form-label">Description</label>
                <textarea class="form-control" id="projDesc" name="projDesc" rows="3"></textarea>
            </div>
            <div class="col-md-6">
                <label for="projLogo" class="form-label">Logo</label>
                <input type="file" class="form-control" id="projLogo" name="projLogo" accept="image/*">
            </div>
            <div class="col-md-6">
                <label for="projSalesExecId" class="form-label">Sales Executive <span>*</span></label>
                <select id="projSalesExecId" name="projSalesExecId" class="form-select" required>
                    <option value="" disabled selected>Select...</option>
                    <?php
                    $users = $productClass->AllEmployeesAndManagersArray();
                    foreach ($users as $user) {
                        $userId = $user["acc_id"];
                        $name = $user["acc_name"];
                        echo "<option value='$userId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projClientCoordinatorId" class="form-label">Client Coordinator <span>*</span></label>
                <select id="projClientCoordinatorId" name="projClientCoordinatorId" class="form-select" required>
                    <option value="" disabled selected>Select...</option>
                    <?php
                    $users = $productClass->AllEmployeesAndManagersArray();
                    foreach ($users as $user) {
                        $userId = $user["acc_id"];
                        $name = $user["acc_name"];
                        echo "<option value='$userId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projManagerId" class="form-label">Project Manager <span>*</span></label>
                <select id="projManagerId" name="projManagerId" class="form-select" required>
                    <option value="" disabled selected>Select...</option>
                    <?php
                    $users = $productClass->AllEmployeesAndManagersArray();
                    foreach ($users as $user) {
                        $userId = $user["acc_id"];
                        $name = $user["acc_name"];
                        echo "<option value='$userId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projdesigner" class="form-label">Designer <span>*</span></label>
                <select id="projdesigner" name="projdesigner[]" class="multiple-select-field" data-placeholder="Select Designer" multiple>
                    <?php
                    $users = $productClass->AllEmployeesAndManagersArray();
                    foreach ($users as $user) {
                        $userId = $user["acc_id"];
                        $name = $user["acc_name"];
                        echo "<option value='$userId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projdeveloper" class="form-label">Developer <span>*</span></label>
                <select id="projdeveloper" name="projdeveloper[]" class="multiple-select-field" data-placeholder="Select Developer" multiple>
                    <?php
                    $users = $productClass->AllEmployeesAndManagersArray();
                    foreach ($users as $user) {
                        $userId = $user["acc_id"];
                        $name = $user["acc_name"];
                        echo "<option value='$userId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projworker" class="form-label">Worker <span>*</span></label>
                <select id="projworker" name="projworker[]" class="multiple-select-field" data-placeholder="Select Worker" multiple>
                    <?php
                    $users = $productClass->AllEmployeesAndManagersArray();
                    foreach ($users as $user) {
                        $userId = $user["acc_id"];
                        $name = $user["acc_name"];
                        echo "<option value='$userId'>$name</option>";
                    }
                    ?>
                </select>
            </div>
            <div class="col-md-6">
                <label for="projPropDate" class="form-label">Proposal Date <span>*</span></label>
                <input type="date" class="form-control" name="projPropDate" id="projPropDate" required>
            </div>
            <div class="col-md-6">
                <label for="projStartDate" class="form-label">Start Date <span>*</span></label>
                <input type="date" class="form-control" name="projStartDate" id="projStartDate" required>
            </div>
            <div class="col-md-6">
                <label for="projDesignStartDate" class="form-label">Design Start Date <span>*</span></label>
                <input type="date" class="form-control" name="projDesignStartDate" id="projDesignStartDate" required>
            </div>
            <div class="col-md-6">
                <label for="projDevelopmentStartDate" class="form-label">Development Start Date <span>*</span></label>
                <input type="date" class="form-control" name="projDevelopmentStartDate" id="projDevelopmentStartDate" required>
            </div>
            <div class="col-md-6">
                <label for="projDevelopmentEndDate" class="form-label">Development End Date <span>*</span></label>
                <input type="date" class="form-control" name="projDevelopmentEndDate" id="projDevelopmentEndDate" required>
            </div>
            <div class="col-md-12">
                <button type="submit" class="btn btn-grd-primary px-4">Submit</button>
            </div>
        </form>
    </div>
</div>

<?php
include_once 'footer.php';
?>