<?php




echo '<style>' . "\r\n\t" . '#cimg{max-width:100%;max-height:25em;object-fit:scale-down;object-position:center center;}' . "\r\n" . '</style>' . "\r\n" . '<main class="h-full pb-16 overflow-y-auto">' . "\r\n\t" . '<div class="container px-6 mx-auto grid">' . "\r\n\t\t" . '<h2' . "\r\n\t\t" . 'class="my-6 text-2xl font-semibold text-gray-700 dark:text-gray-200"' . "\r\n\t\t" . '>' . "\r\n\t\t";
echo (isset($id) ? 'Editar pedido' : 'Novo pedido');
echo ' <a href="./?page=orders"><button class="px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">' . "\r\n\t\t\t" . 'Voltar' . "\r\n\t\t" . '</button></a>' . "\r\n\t" . '</h2>' . "\r\n\r\n\r\n\t" . '<div class="px-4 py-3 mb-2 bg-white rounded-lg shadow-md dark:bg-gray-800">' . "\r\n\t\t" . '<form action="" id="manage-order" autocomplete="off">' . "\t\r\n\r\n" . '            <label class="block text-sm mb-2">' . "\r\n\t\t\t\t" . '<span class="text-gray-700 dark:text-gray-400">Campanha</span>' . "\r\n\t\t\t\t" . '<select name="raffle" id="raffle" class="mr-2 mb-2 block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray">' . "\r\n" . '                    <option value="">Selecione</option>' . "\r\n" . '                    ';
$qry = $conn->query('SELECT id, name FROM `product_list`');

while ($row = $qry->fetch_assoc()) {
	echo '                <option value="';
	echo $row['id'];
	echo '">';
	echo $row['name'];
	echo '</option>' . "\r\n" . '                ';
}

echo '                </select>' . "\r\n\t\t\t" . '</label>' . "\r\n\r\n" . '            <label class="block text-sm mb-2">' . "\r\n\t\t\t\t" . '<span class="text-gray-700 dark:text-gray-400">Cliente</span>' . "\r\n\t\t\t\t" . '<input name="customer" id="customer" type="number" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"' . "\r\n\t\t\t\t" . 'placeholder="Informe o número do cliente"/>' . "\r\n\t\t\t" . '</label>' . "\r\n\r\n" . '            <label class="block text-sm mb-2">' . "\r\n\t\t\t\t" . '<span class="text-gray-700 dark:text-gray-400">Quantidade</span>' . "\r\n\t\t\t\t" . '<input name="quantidade" id="quantidade" type="number" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"' . "\r\n\t\t\t\t" . 'placeholder="Números"/>' . "\r\n\t\t\t" . '</label>' . "\r\n\r\n" . '            <label class="block text-sm mb-2">' . "\r\n\t\t\t\t" . '<span class="text-gray-700 dark:text-gray-400">Números</span>' . "\r\n" . '                <p style="font-size:13px;color: orange;font-style:italic;"><strong>ATENÇÃO! </strong>Adicione os números com a quantidade correta de dígitos e sempre com uma vírgula no final e sem espaços, ex.: <strong>12345,54321,11111,22222,</strong></p>' . "\r\n\t\t\t\t" . '<input name="order_numbers" id="order_numbers" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"' . "\r\n\t\t\t\t" . 'placeholder="Números"/>' . "\r\n\t\t\t" . '</label>' . "\r\n\r\n" . '            <label class="block mt-4 text-sm">' . "\r\n\t\t\t\t" . '<span class="text-gray-700 dark:text-gray-400">Valor</span>' . "\r\n\t\t\t\t" . '<input name="price" id="price" type="number" step="0.01" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"' . "\r\n\t\t\t\t" . 'placeholder="10,00"/>' . "\r\n\t\t\t" . '</label>' . "\r\n\r\n" . '            <label class="block mt-4 text-sm">' . "\r\n\t\t\t\t" . '<span class="text-gray-700 dark:text-gray-400">' . "\r\n\t\t\t\t\t" . 'Status' . "\r\n\t\t\t\t" . '</span>' . "\r\n\t\t\t\t" . '<select name="status" id="status" class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray">' . "\r\n" . '                    <option value="">Selecione</option>' . "\r\n" . '                    <option value="1">Pendente</option>' . "\r\n" . '                    <option value="2">Aprovado</option>' . "\r\n\t\t\t" . '    </select>' . "\r\n\t\t" . '    </label>' . "\r\n\t\t" . '</form>' . "\r\n\r\n\t" . '</div>' . "\r\n\r\n\t\t" . '<div class="mt-2">' . "\r\n\t\t\t" . '<button form="manage-order" class="px-5 py-3 font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">' . "\r\n\t\t\t\t" . 'Cadastrar' . "\r\n\t\t\t" . '</button>' . "\r\n\t\t" . '</div>' . "\r\n\r\n\t\t" . '</main>' . "\r\n\t\t";
$msg = '';
echo '        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.min.js"></script>' . "\r\n\t\t" . '<script>' . "\r\n\t\t\t" . '$(\'#manage-order\').submit(function(e){' . "\r\n\t\t\t\t" . 'e.preventDefault();' . "\r\n\t\t\t\t" . '$.ajax({' . "\r\n\t\t\t\t\t" . 'url:_base_url_+\'class/Main.php?action=create_order\',' . "\r\n\t\t\t\t\t" . 'data: new FormData($(this)[0]),' . "\r\n\t\t\t\t\t" . 'cache: false,' . "\r\n\t\t\t\t\t" . 'contentType: false,' . "\r\n\t\t\t\t\t" . 'processData: false,' . "\r\n\t\t\t\t\t" . 'method: \'POST\',' . "\r\n\t\t\t\t\t" . 'type: \'POST\',' . "\r\n\t\t\t\t\t" . 'success:function(resp){' . "\r\n\t\t\t\t\t\t" . 'var returnedData = JSON.parse(resp);' . "\r\n\t\t\t\t\t\t" . 'if(returnedData.status == \'success\'){' . "\r\n\t\t\t\t\t\t\t" . 'alert(\'Pedido criado com sucesso!\');' . "\r\n\t\t\t\t\t\t\t" . 'location.href=\'./?page=orders\';' . "\r\n\t\t\t\t\t\t" . '} else if(returnedData.status == \'failed\'){' . "\r\n\t\t\t\t\t\t\t" . 'alert(returnedData.msg);' . "\r\n\t\t\t\t\t\t" . '} else {' . "\r\n\t\t\t\t\t\t\t" . 'console.log(resp)' . "\r\n\t\t\t\t\t\t\t" . 'alert("[OC01] - Erro ao criar pedido manual");' . "\t\t\t\t\t\t\r\n\t\t\t\t\t\t" . '}' . "\r\n\t\t\t\t\t" . '}' . "\r\n\t\t\t\t" . '})' . "\r\n\t\t\t" . '})' . "\r\n\r\n" . '            $(document).on(\'input\', \'.discount_price\', function() {' . "\r\n" . '                $(this).mask("#.##0,00", {reverse: true});' . "\r\n" . '            });' . "\r\n\r\n" . '            ' . "\r\n\t\t" . '</script>';

?>