Fullcalendar put image in different sql

Asked

Viewed 102 times

0

Guys I have a calendar of API FullCalendar, he pulls the events of the bank, until there quiet, he pulls well, but for each sql, because the information is from several different tables, I would like a different image. That’s what it is today :

PHP

$sql = "SELECT id, title, descricao, start, end, color FROM events where responsavel like '%".$LOG_NOME."%'";
//$sql .= ";";
$sql2 = "SELECT TA_ID as id, TA_TAREFA as title, TA_DESCRICAO as descricao, TA_PRAZO as start, TA_PRAZO as end, color FROM db_tarefas WHERE TA_SOLICITADO like '%".$LOG_NOME."%' AND (TA_STATUS = 'NOVA' OR TA_STATUS = 'EM ANDAMENTO')";
//$sql .= ";";
//var_dump($sql);
//echo '<tr><td> '. $FET_ASSISTENCIA["AS_EQUIPE_VIATURA"] . '</td> <td>' . $FET_ASSISTENCIA["AS_EQUIPE_SOCORRISTA"] .'</td><td>'. $FET_ASSISTENCIA["AS_EQUIPE_ENFERMAGEM"] .'</td><td>' . $FET_ASSISTENCIA["AS_EQUIPE_MEDICO"] . '</td>';
$sql3 = "SELECT AS_EQUIPE_VIATURA as viatura, AS_EQUIPE_MEDICO as medico, AS_EQUIPE_SOCORRISTA as socorrista, AS_EQUIPE_ENFERMEIRO as enfermagem, AS_SERVICO_TIPO as tipo, AS_SERVICO_TIPO as tipoS,  AS_ID as id, AS_EMPRESA_NOME as title, AS_PACIENTE_NOME as descricao, AS_EVENTO_FINAL as start, AS_EVENTO_FINAL as end, '#696969' as color FROM db_assistencias WHERE AS_EVENTO_FINAL is not null AND AS_EVENTO_FINAL != '0000-00-00 00:00:00' AND AS_EXCLUIDO='' ";

$sql4 = "SELECT lans_id as id, lans_id_funcionario as title, lans_id_funcionario as funcionario, lans_id_funcionario as descricao, lans_id_dia as start, lans_id_dia as end, '#696985' as color, extra_subs as extra, lans_valor as valor FROM db_lancamento_substituto WHERE extra_subs = 'SIM'  AND lans_id_dia is not null AND lans_id_dia != '0000-00-00 00:00:00' ";

$req = $bdd->prepare($sql);
$req->execute();

$events = $req->fetchAll();

//segundo sql
$req2 = $bdd->prepare($sql2);
$req2->execute();
$events2 = $req2->fetchAll();

$req3 = $bdd->prepare($sql3);
$req3->execute();
$events3 = $req3->fetchAll();

$req4 = $bdd->prepare($sql4);
$req4->execute();
$events4 = $req4->fetchAll();

foreach ($events2 as $event2) {
	//$event2['start'] = new DateTime($event2['start']);      
	//$event2['end'] = new DateTime($event2['end']);
	//var_dump($event2['end']);
	array_push($events, $event2);
}

foreach ($events4 as $event4) {
	if($event4['extra'] == 'SIM'){
		if($event4['valor'] == "")
			$event4['color'] = '#FF00FF';
	}
	array_push($events, $event4);
}

foreach ($events3 as $event3) {
	if(($event3['tipo'] == 'EVENTOS') || ($event3['tipoS'] == 'EVENTOS')){
		if($event3['enfermagem'] == "")
			$event3['color'] = '#FF0000';
		if($event3['socorrista'] == "")
			$event3['color'] = '#FF0000';
		if($event3['viatura'] == "")
			$event3['color'] = '#FF0000';
		$viatura = explode("-",$event3['viatura']);
	 	$SQL_VIATURA = $mysqli->query("SELECT * FROM db_viaturas where VT_ID = '". $viatura[0] ."'");
	 	$FET_VIATURA = mysqli_fetch_array($SQL_VIATURA);	 		
	 	if($FET_VIATURA['VT_TIPO'] == "USA"){
	 		if($event3['medico'] == "")
				$event3['color'] = '#FF0000';
	 	}	 
	}
	array_push($events, $event3);
}

And this is where you switch to the image:

eventRender: function(event, element) {
                if(event.color == "#FF0000") {
                    $(element).find('.fc-content').html('<center><img width="30px" src="../img/vermelha.png" />');
                }else{
                    $(element).find('.fc-content').html('<center><img width="30px" src="../img/cinza.png" />');
                }
                if(event.color == "#FF00FF"){
                    $(element).find('.fc-content').html('<center><img width="30px" src="../img/carinhacinza.png" />');
                }else{
                    $(element).find('.fc-content').html('<center><img width="30px" src="../img/carinhavermelha.png" />');
                }

                element[0].style['cssText'] = "background-color: rgba(255, 255, 0, 0); border-color: rgba(0, 0, 0, 0);";
                $(element).tooltip({title: event.title});

            },

The problem is he only pulls the first if, and does not pull separately, each if.

On the 12th he should appear the second IF that are the guys

No dia 12 ele deveria aparecer o segundo IF que são as carinhas

Any suggestions? Thank you.

  • The function eventRender acts on the object event. So, it’s easier to help if you can show the php answer, the object (or array) returned.

  • edited the comment, showing what’s in my php @Shutupmagda

  • No... I mean the object json that you are passing to the variable events of fullCalendar. The response of the consultation at the bank, with the php. Example: [{"title":"Descricao do evento 1","start":"2017-01-11"},{"title":"Descricao do evento 2","start":"2017-01-12"},{"title":"Descricao do evento 3","start":"2017-01-13"}].

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.