controllers/ListaController.php
//public function actionBuscarchofer($id)
public function actionBuscarchofer($id)
public function actionBuscarchofer ( $id )
public function actionBuscarchofer()
    {
        $id =  Yii::$app->request->post('id_empresa');
        $id_empresa = $id;
        if ($id_empresa != null) {
            $empresachoferes = Empresachofer::findAll(['EMPRESA_ID'=>$id_empresa, 'BLOQUEADO'=>'0']);
            if (count($empresachoferes) > 0) {
                    foreach ($empresachoferes as $empresachofer) {
                        $chofer = Chofer::findOne(['ID'=>$empresachofer->CHOFER_ID]);
                        echo "<option value='" . $chofer->ID . "'>" . $chofer->PRIMER_NOMBRE." ".$chofer->PRIMER_APELLIDO . "</option>";
                    }
                } else {
                    echo "'<option>No hay choferes disponibles</option>'";
                }
            }
    }
public function actionBuscarchofer ( ) { $ id = Yii :: $ app -> request -> post ( 'id_empresa' ) ; $ id_empresa = $ id ; if ( $ id_empresa != null ) { $ empresachoferes = Empresachofer :: findAll ( [ 'EMPRESA_ID' => $ id_empresa , 'BLOQUEADO' => '0' ] ) ; if ( count ( $ empresachoferes ) > 0 ) { foreach ( $ empresachoferes as $ empresachofer ) { $ chofer = Chofer :: findOne ( [ 'ID' => $ empresachofer -> CHOFER_ID ] ) ; echo " <option value=' " . $ chofer -> ID . " '> " . $ chofer -> PRIMER_NOMBRE . " " . $ chofer -> PRIMER_APELLIDO . " </option> " ; } } else { echo " '<option>No hay choferes disponibles</option>' " ; } } }
public function actionBuscarchofer($id)
public function actionBuscarchofer ( $id )
//$id_empresa =  [':id_empresa' => Yii::$app->request->post('id_empresa')]; //echo $id;die; //$choferes = Chofer::find(['EMPRESA_ID'=>$id_empresa])->with('empresaChofers')->all(); //$choferes = EmpresaChofer::find(['EMPRESA_ID'=>$id_empresa])->select(['chofer.ID as ID', 'chofer.PRIMER_NOMBRE as PRIMER_NOMBRE'])->with('cHOFER')->all(); //var_dump($empresaChoferes);die; //echo count($empresaChoferes);die; //$chofer = $empresaChofer->cHOFER;