<?php
if (!class_exists('crm_hardlock')) require_once("common_cadline_libraries/crm_hardlock.class.php");

$ctrID = isset($_GET['cnt']) ? $_GET['cnt'] : '';

$dealers    = crm_hardlock::GetDealers();
$userID     = crm_hardlock::GetUserIdFromToken($_GET['userid']);
$selected   = false;

if ($userID < 0)
    $selected = 11;

$resource = new Resource($ctrID);
?>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="/templates/shaper_helix3/css/bootstrap.min.css">

    <title>Dealer select</title>
</head>

<body>
    <div class="container">
        <h3><?= $resource->getDlgString('10999') ?></h3>
        <form action="progress.php" method="post">
            <input type="hidden" name="userID" value="<?= $userID ?>" />
            <input type="hidden" name="cnt" value="<?= $_GET['cnt'] ?>" />
            <input type="hidden" name="action" value="select_distributor" />

            <select name="distID" class="form-control" required>
                <option value="">------ <?= $resource->getDlgString('11003') ?> ------</option>
                <?php foreach ($dealers as $dealer) : ?>
                    <option value="<?= $dealer['id'] ?>" <?= $dealer['id'] == $_GET['selectedDealer'] || $selected ==  $dealer['id'] ? 'selected' : '' ?>>
                        <?= $dealer['name'] ?>
                    </option>
                <?php endforeach; ?>
                <option value="-1"><?= $resource->getDlgString('11012') ?></option>
            </select>
            <br />

            <input type="submit" value="<?= $resource->getDlgString('11023') ?>" class="btn btn-success" />
        </form>
    </div>
</body>

</html>