コード例 #1
0
 function addToTokenattmap()
 {
     $iParticipantId = Yii::app()->request->getPost('participant_id');
     $iSurveyId = Yii::app()->request->getPost('surveyid');
     $mapped = Yii::app()->request->getPost('mapped');
     $newcreate = Yii::app()->request->getPost('newarr');
     $overwriteauto = Yii::app()->request->getPost('overwrite');
     $overwriteman = Yii::app()->request->getPost('overwriteman');
     $overwritest = Yii::app()->request->getPost('overwritest');
     $createautomap = Yii::app()->request->getPost('createautomap');
     $clang = $this->getController()->lang;
     if (empty($newcreate[0])) {
         $newcreate = array();
     }
     $response = Participants::model()->copytosurveyatt($iSurveyId, $mapped, $newcreate, $iParticipantId, $overwriteauto, $overwriteman, $overwritest, $createautomap);
     printf($clang->gT("%s participants have been copied to the survey token table"), $response['success']);
     if ($response['duplicate'] > 0) {
         echo "\r\n";
         printf($clang->gT("%s entries were not copied because they already existed"), $response['duplicate']);
     }
     if ($response['overwriteauto'] == "true" || $response['overwriteman'] == "true") {
         echo "\r\n";
         $clang->eT("Attribute values for existing participants have been updated from the participants records");
     }
 }
コード例 #2
0
 function actionparticipants()
 {
     $surveyid = Yii::app()->request->getQuery('surveyid');
     $langcode = Yii::app()->request->getQuery('langcode');
     $token = Yii::app()->request->getQuery('token');
     Yii::app()->loadHelper('database');
     Yii::app()->loadHelper('sanitize');
     $sLanguageCode = $langcode;
     $iSurveyID = $surveyid;
     $sToken = $token;
     $sToken = sanitize_token($sToken);
     if (!$iSurveyID) {
         $this->redirect(Yii::app()->getController()->createUrl('/'));
     }
     $iSurveyID = (int) $iSurveyID;
     //Make sure it's an integer (protect from SQL injects)
     //Check that there is a SID
     // Get passed language from form, so that we dont lose this!
     if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
         $baselang = Survey::model()->findByPk($iSurveyID)->language;
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($baselang);
     } else {
         $sLanguageCode = sanitize_languagecode($sLanguageCode);
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($sLanguageCode);
         $baselang = $sLanguageCode;
     }
     Yii::app()->lang = $clang;
     $thissurvey = getSurveyInfo($iSurveyID, $baselang);
     if ($thissurvey == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
         $html = $clang->gT('This survey does not seem to exist.');
     } else {
         $row = Tokens_dynamic::getEmailStatus($iSurveyID, $sToken);
         $datas = Tokens_dynamic::model($iSurveyID)->find('token = :token', array(":token" => $sToken));
         if ($row == false) {
             $html = $clang->gT('You are not a participant in this survey.');
         } else {
             $usresult = $row['emailstatus'];
             if ($usresult == 'OK') {
                 $usresult = Tokens_dynamic::updateEmailStatus($iSurveyID, $sToken, 'OptOut');
                 $html = $clang->gT('You have been successfully removed from this survey.');
             } else {
                 $html = $clang->gT('You have been already removed from this survey.');
             }
             if (!empty($datas->participant_id) && $datas->participant_id != "") {
                 //Participant also exists in central db
                 $cpdb = Participants::model()->find('participant_id = :participant_id', array(":participant_id" => $datas->participant_id));
                 if ($cpdb->blacklisted == "Y") {
                     $html .= "<br />";
                     $html .= $clang->gt("You have already been removed from the central participants list for this site");
                 } else {
                     $cpdb->blacklisted = 'Y';
                     $cpdb->save();
                     $html .= "<br />";
                     $html .= $clang->gT("You have been removed from the central participants list for this site");
                 }
             }
         }
     }
     //PRINT COMPLETED PAGE
     if (!$thissurvey['templatedir']) {
         $thistpl = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
     } else {
         $thistpl = getTemplatePath($thissurvey['templatedir']);
     }
     $this->_renderHtml($html, $thistpl);
 }
コード例 #3
0
ファイル: dates.php プロジェクト: martinbrylski/admidio
         $outputLinkLocation = $date->getValue('dat_location');
     }
 }
 // if active, then show room information
 if ($date->getValue('dat_room_id') > 0) {
     $room = new TableRooms($gDb, $date->getValue('dat_room_id'));
     if ($getViewMode === 'html') {
         $roomLink = $g_root_path . '/adm_program/system/msg_window.php?message_id=room_detail&amp;message_title=DAT_ROOM_INFORMATIONS&amp;message_var1=' . $date->getValue('dat_room_id') . '&amp;inline=true';
         $outputLinkRoom = '<strong><a data-toggle="modal" data-target="#admidio_modal" href="' . $roomLink . '">' . $room->getValue('room_name') . '</a></strong>';
     } else {
         $outputLinkRoom = $room->getValue('room_name');
     }
 }
 // count participants of the date
 if ($date->getValue('dat_rol_id') > 0) {
     $participants = new Participants($gDb, $date->getValue('dat_rol_id'));
     $outputNumberMembers = $participants->getCount();
     $outputNumberLeaders = $participants->getNumLeaders();
     if ($getView === 'participants') {
         $participantsArray = $participants->getParticipantsArray($date->getValue('dat_rol_id'));
     }
 }
 // Links for the participation only in html mode
 if ($date->getValue('dat_rol_id') > 0 && $getViewMode === 'html') {
     if ($row['member_date_role'] > 0) {
         $buttonURL = $g_root_path . '/adm_program/modules/dates/dates_function.php?mode=4&amp;dat_id=' . $date->getValue('dat_id');
         if ($getView === 'detail') {
             $outputButtonParticipation = '
                 <button class="btn btn-default" onclick="window.location.href=\'' . $buttonURL . '\'">
                     <img src="' . THEME_PATH . '/icons/no.png" alt="' . $gL10n->get('DAT_CANCEL') . '" />' . $gL10n->get('DAT_CANCEL') . '</button>';
         } else {
コード例 #4
0
 public function postTrabalhocadastro()
 {
     $course = Courses::find(Input::get('course'));
     $usertype = UserTypes::find(Input::get('usertype'));
     $estado = ORGStates::where('id_estado', '=', Input::get('estado'))->take(1)->get();
     $estado_empresa = ORGStates::where('id_estado', '=', Input::get('estado_empresa'))->take(1)->get();
     //dd(Input::all());
     $participant = new ORGParticipants();
     $participant->nome = Input::get('nome') != null ? Input::get('nome') : '';
     $participant->rg = Input::get('rg') != null ? Input::get('rg') : '';
     $participant->cpf = Input::get('cpf') != null ? Input::get('cpf') : '';
     $participant->endereco = Input::get('endereco') != null ? Input::get('endereco') : '';
     $participant->numero = Input::get('numero') != null ? Input::get('numero') : '';
     $participant->complemento = Input::get('complemento') != null ? Input::get('complemento') : '';
     $participant->cep = Input::get('cep') != null ? Input::get('cep') : '';
     $participant->cidade = Input::get('cidade') != null ? Input::get('cidade') : '';
     $participant->estado = isset($estado[0]->name_estado) ? $estado[0]->name_estado : '';
     /*$participant->empresa = Input::get('empresa') != null ? Input::get('empresa') : '';
     		$participant->cnpj = Input::get('cnpj_empresa') != null ? Input::get('cnpj_empresa') : '';
     		$participant->endereco_empresa = Input::get('endereco_empresa') != null ? Input::get('endereco_empresa') : '';
     		$participant->numero_empresa = Input::get('nome') != null ? Input::get('nome') : '';
     		$participant->complemento_empresa = Input::get('complemento_empresa') != null ? Input::get('complemento_empresa') : '';
     		$participant->cep_empresa = Input::get('cep_empresa') != null ? Input::get('cep_empresa') : '';
     		$participant->cidade_empresa = Input::get('cidade_empresa') != null ? Input::get('cidade_empresa') : '';
     		$participant->estado_empresa = isset($estado_empresa[0]->name_estado) ? $estado_empresa[0]->name_estado : '';
     		$participant->celular = Input::get('celular_empresa') != null ? Input::get('celular_empresa') : '';*/
     $participant->telefone = Input::get('telefone_empresa') != null ? Input::get('telefone_empresa') : '';
     $participant->email = Input::get('email') != null ? Input::get('email') : '';
     $participant->save();
     $user = new User();
     $user->email = $participant->email;
     if ($participant->nome != null) {
         $user->name = $participant->nome;
     } else {
         $user->name = "User without name";
     }
     $user->status = 'publish';
     $user->type = 'participant';
     $user->save();
     $participant = ORGParticipants::getByCPF($participant->cpf);
     $part = new Participants();
     $part->participant = $participant[0]->id_participante;
     $part->user = $user->id;
     $part->email = $participant[0]->email;
     $part->name = $participant[0]->nome;
     $part->cpf = $participant[0]->cpf;
     $part->status = 'publish';
     $part->type = 'participant';
     $part->save();
     Auth::user()->login($user);
     if ($inscription = Inscriptions::hasInscription(Auth::user()->user()->id, $course->id)) {
         $array = array('msg_success' => Lang::get('messages.login_welcome'), 'usertype' => $usertype, 'inscription' => $inscription);
         return Redirect::to($course->route . '/arquivos')->with($array);
     } else {
         $inscription = new Inscriptions();
         $inscription->id_course = $course->id;
         $inscription->id_user = Auth::user()->user()->id;
         $inscription->id_usertype = $usertype->id;
         $inscription->save();
         $array = array('usertype' => $usertype, 'inscription' => $inscription);
         return Redirect::to($course->route . '/arquivos')->with($array);
     }
 }
コード例 #5
0
ファイル: Participants.php プロジェクト: rawaludin/LimeSurvey
 function copyToCentral($surveyid, $newarr, $mapped, $overwriteauto = false, $overwriteman = false, $createautomap = true)
 {
     $tokenid = Yii::app()->session['participantid'];
     //List of token_id's to add to participants table
     $duplicate = 0;
     $sucessfull = 0;
     $writearray = array();
     $attid = array();
     //Will store the CPDB attribute_id of new or existing attributes keyed by CPDB at
     $pid = "";
     /* Grab all the existing attribute field names from the tokens table */
     $arr = Yii::app()->db->createCommand()->select('*')->from("{{tokens_{$surveyid}}}")->queryRow();
     if (is_array($arr)) {
         $tokenfieldnames = array_keys($arr);
         $tokenattributefieldnames = array_filter($tokenfieldnames, 'filterForAttributes');
     } else {
         $tokenattributefieldnames = array();
     }
     /* Automatically mapped attribute names are named "attribute_cpdb_[some_number]" */
     foreach ($tokenattributefieldnames as $key => $value) {
         if ($value[10] == 'c') {
             $autoattid = substr($value, 15);
             $mapped[$autoattid] = $value;
         }
     }
     /* Create new CPDB attributes */
     if (!empty($newarr)) {
         foreach ($newarr as $key => $value) {
             /* $key is the fieldname from the token table (ie "attribute_1")
              * $value is the 'friendly name' for the attribute (ie "Gender")
              */
             $insertnames = array('attribute_type' => 'TB', 'visible' => 'Y');
             Yii::app()->db->createCommand()->insert('{{participant_attribute_names}}', $insertnames);
             $attid[$key] = Yii::app()->db->getCommandBuilder()->getLastInsertID('{{participant_attribute_names}}');
             /* eg $attid['attribute_1']='8372' */
             $insertnameslang = array('attribute_id' => $attid[$key], 'attribute_name' => urldecode($value), 'lang' => Yii::app()->session['adminlang']);
             Yii::app()->db->createCommand()->insert('{{participant_attribute_names_lang}}', $insertnameslang);
         }
     }
     /* Add the participants to the CPDB = Iterate through each $tokenid and create the new CPDB id*/
     foreach ($tokenid as $key => $tid) {
         if (is_numeric($tid) && $tid != "") {
             /* Get the data for this participant from the tokens table */
             $tobeinserted = Yii::app()->db->createCommand()->select('participant_id,firstname,lastname,email,language')->where('tid = :tid')->from('{{tokens_' . intval($surveyid) . '}}')->bindParam(":tid", $tid, PDO::PARAM_INT)->queryRow();
             /* See if there are any existing CPDB entries that match on firstname,lastname and email */
             $query = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->where('firstname = :firstname AND lastname = :lastname AND email = :email')->bindParam(":firstname", $tobeinserted['firstname'], PDO::PARAM_STR)->bindParam(":lastname", $tobeinserted['lastname'], PDO::PARAM_STR)->bindParam(":email", $tobeinserted['email'], PDO::PARAM_STR)->queryAll();
             /* If there is already an existing entry, add to the duplicate count */
             if (count($query) > 0) {
                 $duplicate++;
                 //HERE is where we can add "overwrite" feature to update attribute values for existing participants
                 if ($overwriteauto == "true") {
                     if (!empty($newarr)) {
                         foreach ($newarr as $key => $value) {
                             Participants::updateAttributeValueToken($surveyid, $query[0]['participant_id'], $attid[$key], $key);
                         }
                     }
                 }
                 if ($overwriteman == "true") {
                     /* Now add mapped attribute values */
                     if (!empty($mapped)) {
                         foreach ($mapped as $cpdbatt => $tatt) {
                             Participants::updateAttributeValueToken($surveyid, $query[0]['participant_id'], $cpdbatt, $tatt);
                         }
                     }
                 }
             } else {
                 /* Create entry in participants table */
                 $black = !empty($tobeinserted['blacklisted']) ? $tobeinserted['blacklised'] : 'N';
                 $pid = !empty($tobeinserted['participant_id']) ? $tobeinserted['participant_id'] : $this->gen_uuid();
                 $writearray = array('participant_id' => $pid, 'firstname' => $tobeinserted['firstname'], 'lastname' => $tobeinserted['lastname'], 'email' => $tobeinserted['email'], 'language' => $tobeinserted['language'], 'blacklisted' => $black, 'owner_uid' => Yii::app()->session['loginID']);
                 Yii::app()->db->createCommand()->insert('{{participants}}', $writearray);
                 //Update token table and insert the new UUID
                 $data = array("participant_id" => $pid);
                 Yii::app()->db->createCommand()->update('{{tokens_' . intval($surveyid) . '}}', $data, "tid = {$tid}");
                 /* Now add any new attribute values */
                 if (!empty($newarr)) {
                     foreach ($newarr as $key => $value) {
                         Participants::updateAttributeValueToken($surveyid, $pid, $attid[$key], $key);
                     }
                 }
                 /* Now add mapped attribute values */
                 if (!empty($mapped)) {
                     foreach ($mapped as $cpdbatt => $tatt) {
                         Participants::updateAttributeValueToken($surveyid, $pid, $cpdbatt, $tatt);
                     }
                 }
                 $sucessfull++;
                 /* Create a survey_link */
                 $data = array('participant_id' => $pid, 'token_id' => $tid, 'survey_id' => $surveyid, 'date_created' => date(DATE_W3C, time()));
                 Yii::app()->db->createCommand()->insert('{{survey_links}}', $data);
             }
         }
     }
     if (!empty($newarr)) {
         /* Rename the token attribute fields to a cpdb field, so in future
          * we know that it belongs to a CPDB field */
         foreach ($newarr as $key => $value) {
             $newname = 'attribute_cpdb_' . intval($attid[$key]);
             $fields = array($value => array('name' => $newname, 'type' => 'TEXT'));
             //Rename the field in the tokens_[sid] table
             Yii::app()->db->createCommand()->renameColumn('{{tokens_' . intval($surveyid) . '}}', $key, $newname);
             //Make the field a TEXT field
             Yii::app()->db->createCommand()->alterColumn('{{tokens_' . intval($surveyid) . '}}', $newname, 'TEXT');
             $previousatt = Yii::app()->db->createCommand()->select('attributedescriptions')->from('{{surveys}}')->where("sid = " . $surveyid);
             $patt = $previousatt->queryRow();
             $previousattribute = unserialize($patt['attributedescriptions']);
             $previousattribute[$newname] = $previousattribute[$key];
             unset($previousattribute[$key]);
             $previousattribute = serialize($previousattribute);
             Yii::app()->db->createCommand()->update('{{surveys}}', array("attributedescriptions" => $previousattribute), 'sid = ' . $surveyid);
             //load description in the surveys table
         }
     }
     if (!empty($mapped)) {
         foreach ($mapped as $cpdbatt => $tatt) {
             if ($tatt[10] != 'c' && $createautomap == "true") {
                 // Change the fieldname in the token table to attribute_cpdb_[participant_attribute_id]
                 // so future mapping is done automatically
                 $newname = 'attribute_cpdb_' . $cpdbatt;
                 $fields = array($tatt => array('name' => $newname, 'type' => 'TEXT'));
                 Yii::app()->db->createCommand()->renameColumn('{{tokens_' . intval($surveyid) . '}}', $tatt, $newname);
                 Yii::app()->db->createCommand()->alterColumn('{{tokens_' . intval($surveyid) . '}}', $newname, 'TEXT');
                 $previousatt = Yii::app()->db->createCommand()->select('attributedescriptions')->from('{{surveys}}')->where("sid = :sid")->bindParam(":sid", $surveyid, PDO::PARAM_INT);
                 $previousattribute = $previousatt->queryRow();
                 $previousattribute = unserialize($previousattribute['attributedescriptions']);
                 $previousattribute[$newname] = $previousattribute[$tatt];
                 unset($previousattribute[$tatt]);
                 //Rename the token field the name of the participant_attribute
                 $attributedetails = ParticipantAttributeNames::getAttributeNames($cpdbatt);
                 $previousattribute[$newname]['description'] = $attributedetails[0]['attribute_name'];
                 $previousattribute = serialize($previousattribute);
                 //$newstring = str_replace($tatt, $newname, $previousattribute['attributedescriptions']);
                 Yii::app()->db->createCommand()->update('{{surveys}}', array("attributedescriptions" => $previousattribute), 'sid = ' . $surveyid);
             }
         }
     }
     $returndata = array('success' => $sucessfull, 'duplicate' => $duplicate, 'overwriteauto' => $overwriteauto, 'overwriteman' => $overwriteman);
     return $returndata;
 }
コード例 #6
0
ファイル: dates.php プロジェクト: bash-t/admidio
} else {
    $datesPerPage = $dates->getDataSetCount();
}
// read relevant events from database
$datesResult = $dates->getDataset($getStart, $datesPerPage);
$datesTotalCount = $dates->getDataSetCount();
if ($getId == 0 || $getViewMode === 'compact' && $getId > 0) {
    // Navigation of the module starts here
    $gNavigation->addStartUrl(CURRENT_URL, $dates->getHeadline($getHeadline));
}
// read all events for output
if ($datesTotalCount != 0) {
    // Initialize counter and object instances
    $count = 0;
    $date = new TableDate($gDb);
    $participants = new Participants($gDb);
    // New array for the participants of a date
    $memberElements = array();
    // Loop date array and add further information in right position of each date.
    foreach ($datesResult['recordset'] as $row) {
        $date->readDataById($row['dat_id']);
        // get avaiable room information
        if ($date->getValue('dat_room_id') > 0) {
            $room = new TableRooms($gDb, $date->getValue('dat_room_id'));
            $datesResult['recordset'][$count]['room_name'] = $room->getValue('room_name');
        }
        // count members and leaders of the date role and push the result to the array
        if ($date->getValue('dat_rol_id') !== null) {
            $datesResult['recordset'][$count]['dat_num_members'] = $participants->getCount($date->getValue('dat_rol_id'));
            $datesResult['recordset'][$count]['dat_num_leaders'] = $participants->getNumLeaders($date->getValue('dat_rol_id'));
        }
コード例 #7
0
 public function getExportinscriptions($idCourse)
 {
     $course = Courses::find($idCourse);
     $inscriptions = $course->inscriptions;
     $users = array();
     $trainings = ORGTrainings::all();
     $states = ORGStates::all();
     $towns = ORGTowns::all();
     $h = 0;
     foreach ($inscriptions as $ins) {
         # code...
         // var_dump($ins->id);
         if ($ins->user->type == "associate" || $ins->user->id == 127) {
             // var_dump($ins->user->id);
             // var_dump($ins->user->type);
             $tempuser = Associates::where('user', '=', $ins->user->id)->take(1)->get();
             $users[$ins->id] = $tempuser[0]->asociado;
         } elseif ($ins->user->type == "participant" && $ins->user->id != 127) {
             $tempuser = Participants::where('user', '=', $ins->user->id)->take(1)->get();
             // if($h>30)
             // 	dd($ins->user->id);
             // else
             // 	var_dump($tempuser[0]->id);
             $users[$ins->id] = $tempuser[0]->participante;
             // }
             /*if(isset($tempuser[0])):
             			$users[$ins->id]=$tempuser[0]->participante;
             		else:
             			var_dump($ins->user->type);
             			dd($ins->user->id);
             		endif;*/
         }
         $h++;
     }
     // foreach($inscriptions as $inscription):
     // 	// $total["name"] = $inscription->user->name;
     // 	// $total["email"] = $inscription->user->email;
     // 	// $total["paid"] = $inscription->paid;
     // 	// $total["date"] = date_format(date_create($inscription->created_at), 'd-m-Y');
     // 	// $total["type"] = $inscription->usertype->title;
     // 	$total= ["nome" => $inscription->user->name,
     // 			 "email" => $inscription->user->email,
     // 			 "paid" => $inscription->paid,
     // 			 "date" => date_format(date_create($inscription->created_at), 'd-m-Y'),
     // 			 "type" => $inscription->usertype->title
     // 			 ];
     // 	// break;
     // 	// array_push($total,$inscription->user->name,$inscription->user->email);
     // endforeach;
     // dd($inscriptions);
     Excel::create('Export Inscriptions ' . $course->title . "-" . rand(2, 700 * date("H")) . "-" . date("d-m-Y"), function ($excel) use($inscriptions, $users) {
         $excel->sheet('Excel sheet', function ($sheet) use($inscriptions, $users) {
             $sheet->setOrientation('portrait');
             $n = 2;
             // $sheet->appendRow(1,array("Codigo Asociado","Nome","RG","Email", "Telefone", "Celular", "CPF", "Tipo Pessoa","Pagamento", "Fecha", "User Type", "Endereço", "Complemento", "CEP", "Cidade", "Estado", "Empresa", "Endereço Empresa", "Complemento Empresa", "Telefone Empresa", "CNPJ", "Cargo" ));
             // $inscriptions = $inscriptions;
             foreach ($inscriptions as $inscription) {
                 // $total["name"] = $inscription->user->name;
                 // $total["email"] = $inscription->user->email;
                 // $total["paid"] = $inscription->paid;
                 // $total["date"] = date_format(date_create($inscription->created_at), 'd-m-Y');
                 // $total["type"] = $inscription->usertype->title;
                 if ($inscription->paid == 0) {
                     $paid = "Não";
                 } else {
                     $paid = "Sim";
                 }
                 if ($inscription->user->type == 'associate' || $inscription->user->id == 127) {
                     // if(isset($users[$inscription->id]->codigo_asoc)){
                     // 	var_dump($users[$inscription->id]->nombre_completo);
                     // }else{
                     // 	dd($inscription->user->id);
                     // }
                     $cod_aso = $users[$inscription->id]->codigo_asoc;
                     $nome = $users[$inscription->id]->nombre_completo;
                     $rg = "";
                     //No agregados
                     $incripcion_estadual = $users[$inscription->id]->inscripcion_estadual;
                     $incripcion_municipal = $users[$inscription->id]->inscripcion_municipal;
                     $data_nascimento = $users[$inscription->id]->data_nascimento;
                     $training = ORGTrainings::find($users[$inscription->id]->formacao);
                     if ($training) {
                         $training = $training->nome;
                     } else {
                         $training = "";
                     }
                     $categoria_titulo = ORGAssociateCategories::all();
                     foreach ($categoria_titulo as $cat) {
                         if ($users[$inscription->id]->categoria == $cat->id_categoria_asociado) {
                             $categoria_titulo = $cat->nombre_categoria;
                             break;
                         }
                     }
                     $logradouro_res = "";
                     $backyards = ORGBackyards::all();
                     foreach ($backyards as $backyard) {
                         if ($users[$inscription->id]->logradouro_res == $backyard->id_logradouro) {
                             $logradouro_res = $backyard->nombre;
                             break;
                         }
                     }
                     $logradouro_com = "";
                     foreach ($backyards as $backyard) {
                         if ($users[$inscription->id]->logradouro_com == $backyard->id_logradouro) {
                             $logradouro_res = $backyard->nombre;
                             break;
                         }
                     }
                     $barrio_res = $users[$inscription->id]->bairro_res;
                     $barrio_com = $users[$inscription->id]->bairro_com;
                     $pasaporte = $users[$inscription->id]->passaporte;
                     $website = $users[$inscription->id]->web_site;
                     $responsable = $users[$inscription->id]->responsavel;
                     $publicaciones = $users[$inscription->id]->publicacoes;
                     $nombre_cientifico = $users[$inscription->id]->nome_cientifico;
                     $num_res = $users[$inscription->id]->numero_res;
                     $num_com = $users[$inscription->id]->numero_com;
                     //Fin de no agregados
                     //Campos participants no agregados
                     $cidade_empresa = "";
                     $estado_empresa = "";
                     $cep_empresa = "";
                     $state = "";
                     //Fin de campos participants no agregados
                     $cpf = $users[$inscription->id]->cpf;
                     $razon_social = $users[$inscription->id]->razon_social;
                     $celular = $users[$inscription->id]->celular_res;
                     $tipo_pessoa = $users[$inscription->id]->tipo_pessoa;
                     $data_nascimento = $users[$inscription->id]->data_nascimento;
                     $email = $users[$inscription->id]->email;
                     $data_cadastro = $users[$inscription->id]->data_cadastro;
                     $empresa = $users[$inscription->id]->empresa;
                     $empresa_dir = $users[$inscription->id]->dir_com;
                     $empresa_com = $users[$inscription->id]->complemento_com;
                     $empresa_tel = $users[$inscription->id]->ddd_com . ' ' . $users[$inscription->id]->ddi_com . ' ' . $users[$inscription->id]->telefone_com;
                     $cnpj = $users[$inscription->id]->cnpj;
                     $cargo = $users[$inscription->id]->cargo;
                     $dir = $users[$inscription->id]->dir_res;
                     $cep = $users[$inscription->id]->cep_res;
                     $complemento = $users[$inscription->id]->complemento_res;
                     $telefone = $users[$inscription->id]->ddd_res . ' ' . $users[$inscription->id]->ddi_res . ' ' . $users[$inscription->id]->telefone_res;
                     $estado = '';
                     $cidade = '';
                 } elseif ($inscription->user->type == 'participant') {
                     $cod_aso = "";
                     $nome = $users[$inscription->id]->nome;
                     // Campos de asociados obligatorio
                     $incripcion_estadual = "";
                     $incripcion_municipal = "";
                     $data_nascimento = "";
                     $training = "";
                     $categoria_titulo = "";
                     $logradouro_res = "";
                     $logradouro_com = "";
                     $barrio_res = "";
                     $barrio_com = "";
                     $pasaporte = "";
                     $website = "";
                     $responsable = "";
                     $publicaciones = "";
                     $nombre_cientifico = "";
                     $num_res = $users[$inscription->id]->numero;
                     $num_com = $users[$inscription->id]->numero_empresa;
                     //fin de campos asociados obligatorios
                     //Campos participants no agregados
                     $cidade_empresa = $users[$inscription->id]->cidade_empresa;
                     $estado_empresa = $users[$inscription->id]->estado_empresa;
                     $cep_empresa = $users[$inscription->id]->cep_empresa;
                     $state = ORGStates::all();
                     foreach ($state as $sta) {
                         if ($users[$inscription->id]->estado == $sta->name_estado) {
                             $state = $users[$inscription->id]->estado;
                             break;
                         } elseif ($users[$inscription->id]->estado == $sta->id_estado) {
                             $state = $sta->name_estado;
                             break;
                         }
                     }
                     //Fin de campos participants no agregados
                     $cpf = $users[$inscription->id]->cpf;
                     $rg = $users[$inscription->id]->rg;
                     $razon_social = '';
                     $celular = $users[$inscription->id]->celular;
                     $tipo_pessoa = 'F';
                     $data_nascimento = $users[$inscription->id]->data_nascimento;
                     $email = $users[$inscription->id]->email;
                     $data_cadastro = $users[$inscription->id]->data_cadastro;
                     $empresa = $users[$inscription->id]->empresa;
                     $empresa_dir = $users[$inscription->id]->endereco_empresa;
                     $empresa_com = $users[$inscription->id]->complemento_empresa;
                     $empresa_tel = "";
                     $cnpj = $users[$inscription->id]->cnpj;
                     $cargo = "";
                     $dir = $users[$inscription->id]->dir_res;
                     $cep = $users[$inscription->id]->cep;
                     $complemento = $users[$inscription->id]->complemento;
                     $telefone = $users[$inscription->id]->telefone;
                     $estado = $state;
                     $cidade = $users[$inscription->id]->cidade;
                     $cidade_empresa = $users[$inscription->id]->cidade_empresa;
                 }
                 $sheet->appendRow(1, array("Codigo Asociado", "Nome", "RG", "Email", "Telefone", "Celular", "CPF", "Tipo Pessoa", "Pagamento", "Fecha", "User Type", "Inscription estadual", "Inscription municipal", "Data Nascimento", "Training", "Category Title", "Logradouro Residencia", "Endereço", "Complemento", "Número Res", "Barrio Res", "CEP", "Cidade", "Estado", "Empresa", "Logradouro Empresa", "Endereço Empresa", "Cidade Empresa", "CEP Empresa", "Complemento Empresa", "Número Empresa", "Barrio Empresa", "Telefone Empresa", "CNPJ", "Cargo", "Pasaporte", "Website", "Responsavel", "Nome Cientifico", "Publicacoes"));
                 $total = ["codigo" => $cod_aso, "nome" => $nome, "rg" => $rg, "email" => $email, "telefone" => $telefone, "celular" => $celular, "cpf" => $cpf, "tipo_pessoa" => $tipo_pessoa, "paid" => $paid, "date" => date_format(date_create($inscription->created_at), 'd-m-Y'), "type" => $inscription->usertype->title, "inscription_est" => $incripcion_estadual, "incripcion_municipal" => $incripcion_municipal, "data_nascimento" => $data_nascimento, "training" => $training, "categoria_titulo" => $categoria_titulo, "logradouro_res" => $logradouro_res, "dir" => $dir, "complemento" => $complemento, "num_res" => $num_res, "barrio_res" => $barrio_res, "cep" => $cep, "cidade" => $cidade, "estado" => $estado, "empresa" => $empresa, "logradouro_com" => $logradouro_com, "empresa_dir" => $empresa_dir, "cidade_empresa" => $cidade_empresa, "cep_empresa" => $cep_empresa, "empresa_com" => $empresa_com, "num_com" => $num_com, "barrio_com" => $barrio_com, "empresa_tel" => $empresa_tel, "cnpj" => $cnpj, "cargo" => $cargo, "pasaporte" => $pasaporte, "website" => $website, "responsable" => $responsable, "nome_cientifico" => $nombre_cientifico, "publicaciones" => $publicaciones];
                 $sheet->appendRow($n, $total);
                 // break;
                 $n++;
                 // array_push($total,$inscription->user->name,$inscription->user->email);
             }
         });
     })->export('xlsx');
     // Excel::create('Export Inscriptions '. $course->title ."-". rand(2, 700*date("H"))."-".date("d-m-Y"), function($excel) use ($total){
     //     $excel->sheet('Excel sheet', function($sheet) use ($total){
     //         $sheet->setOrientation('portrait');
     //         	// dd($total);
     //         	$sheet->fromArray($total, null, 'A1', true);
     //     });
     // })->export('xlsx');
 }