Example #1
0
            <div class="label_line">

                <label class="label_small">
                    <span class="field">Data:</span>
                    <input type="text" class="formTimestamp center" name="setor_date" value="<?php 
echo date('d/m/Y H:i:s');
?>
" />
                </label>

                <label class="label_small left">
                    <span class="field">Tipo:</span>
                    <select name="setor_type">
                        <option value=""> Selecione um tipo: </option>
                        <?php 
$ReadSet = new WsSetorType();
$ReadSet->Execute()->findAll();
if (!$ReadSet->Execute()->getResult()) {
    echo '<option disabled="disable" value=""> Cadastre antes um tipo! </option>';
} else {
    foreach ($ReadSet->Execute()->getResult() as $ses) {
        echo "<option value=\"{$ses->type_id}\" ";
        if ($ses->type_id == $data['setor_type']) {
            echo ' selected="seleted" ';
        }
        echo "> {$ses->type_content} </option>";
    }
}
?>
                    </select>
                </label>
Example #2
0
        <header>
            <h1>Atualizar Tipo:</h1>
        </header>

        <?php 
require '_models/AdminSetorType.class.php';
$data = filter_input_array(INPUT_POST, FILTER_DEFAULT);
$typeId = filter_input(INPUT_GET, 'typeId', FILTER_VALIDATE_INT);
if (!empty($data['SendPostForm'])) {
    unset($data['SendPostForm']);
    $data['type_id'] = $typeId;
    $cadastra = new AdminSetorType();
    $cadastra->ExeUpdate($data);
    WSErro($cadastra->getError()[0], $cadastra->getError()[1]);
} else {
    $Read = new WsSetorType();
    $Read->setType_id($typeId);
    $Read->Execute()->Query("#type_id#");
    if (!$Read->Execute()->getResult()) {
        header("Location: painel.php?exe=setor_type/index&empty=true");
    } else {
        $data = (array) $Read->Execute()->getResult()[0];
    }
}
$checkCreate = filter_input(INPUT_GET, 'create', FILTER_VALIDATE_BOOLEAN);
if ($checkCreate && empty($cadastra)) {
    WSErro("O tipo <b>{$data['type_content']}</b> foi cadastrado com sucesso no sistema! Continue atualizando o mesmo!", WS_ACCEPT);
}
?>

        <form name="PostForm" action="" method="post" enctype="multipart/form-data">
 /**
  * Encontra o tipo de setor a partir da descrição
  * 
  * @param string $TypeName
  * @return int
  */
 public static function SetTypeByName($TypeName)
 {
     $Read = new WsSetorType();
     $Read->setType_content($TypeName);
     $query = $Read->Execute()->Query("#type_content# AND type_status = 1");
     if ($Read->Execute()->getResult()) {
         return (int) $query[0]->type_id;
     } else {
         WSErro("O tipo de setor <b>{$TypeName}</b> não foi encontrado!", WS_ERROR);
         return null;
     }
 }
<?php

include "../../_app/Config.inc.php";
$Read = new WsSetorType();
$request = json_decode(file_get_contents("php://input"));
if (!empty($request)) {
    if (!empty($request) && is_array($request)) {
        //excluir
        foreach ($request as $data) {
            $Read->setType_id($data->type_id);
            $Read->Execute()->delete();
        }
        echo "excluido com sucesso!";
    } elseif (!empty($request->edited)) {
        //editar
        $Read->setThis($request);
        $Read->Execute()->update(NULL, "type_id");
        echo "Editado com sucesso!";
    } else {
        //adicionar
        $Read->setThis($request);
        $Read->Execute()->insert();
        echo "Adicionado com sucesso!";
    }
} else {
    $Read->Execute()->Query("type_status=1");
    echo json_encode($Read->Execute()->getResult());
}