/**
  * Creates a new Triagem model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Triagem();
     //var_dump(Yii::$app->user->identity->id);
     if ($model->load(Yii::$app->request->post())) {
         // var_dump(Yii::$app->request->post());
         if (isset($_POST['Triagem']['cpfInteressado']) && $model->interessado == 0) {
             $cpf = $_POST['Triagem']['cpfInteressado'];
             // valida a entrada do usuário e redireciona para a página anterior, caso valide
             $interessadoModel = new InteressadoSearch();
             $interessado = $interessadoModel->getInteressadoByCpf($cpf);
             $model->interessado = $interessado['idInteressado'];
             $model->cpfInteressado = $cpf;
             return $this->render('create', ['model' => $model]);
         } else {
             if (isset($_POST['Triagem']['interessado']) && $_POST['Triagem']['interessado'] != 0 && ($_POST['Triagem']['tipoTriagem'] = !"")) {
                 $model->user_id = Yii::$app->user->identity->id;
                 if ($model->save()) {
                     return $this->redirect(['view', 'id' => $model->id]);
                 }
             }
         }
     }
     if ($model->load(Yii::$app->request->post()) && isset($_POST['Triagem']['tipoTriagem']) && $model->save()) {
         if ($_POST['Triagem']['tipoTriagem'] == "pre_atendimento") {
             return $this->redirect(['preatendimento/create', 'triagem' => $model->id]);
         }
     } else {
         $model->interessado = 0;
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Lists all Interessado models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new InteressadoSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Exemple #3
0
use yii\widgets\MaskedInput;
use yii\helpers\ArrayHelper;
use frontend\models\Interessado;
use frontend\models\Triagem;
use frontend\models\TriagemSearch;
use frontend\models\User;
use frontend\models\Classes;
use frontend\models\InteressadoSearch;
use kartik\widgets\Select2;
use kartik\datecontrol\DateControl;
/* @var $this yii\web\View */
/* @var $model frontend\models\Atendimento */
/* @var $form yii\widgets\ActiveForm */
$triagemSearch = new TriagemSearch();
$triagens = $triagemSearch->getTriagensPreAtendimentoByInteressado();
$interessadoSearch = new InteressadoSearch();
$interessados = $interessadoSearch->getInteressadosWitchCPF();
?>

<div class="atendimento-form">

    <?php 
$form = ActiveForm::begin();
?>
<div class="row">
  <div class="col-md-2"> 
      <?php 
echo $form->field($model, 'numeroprocesso')->widget(MaskedInput::className(), ['mask' => '9999999-99.9999']);
?>
  </div>
  <div class="col-md-4">