Código PHP:
include(TO."CitaTO.php");
include(TO."AccionTO.php");
include(MODEL."ConexionBD.php");
class CitaModel{
function cita($data){
try {
if($data['day']<10)
$data['day'] = '0'.$data['day'];
$fecha = $data['year'].$data['month'].$data['day'];
$db=ConexionBD::getConexion();
$sql=" SELECT e.cal_id,e.cal_time,e.cal_name, e.cal_date, e.cal_description, ce.cal_Estado FROM webcal_entry e
INNER JOIN webcal_entry_user eu
ON e.cal_id = eu.cal_id
LEFT JOIN webcal_close_entry ce
ON ce.cal_entry = e.cal_id
WHERE eu.cal_status = 'A'
AND eu.cal_login = '".$data['login']."'
AND cal_date = '$fecha'
ORDER BY cal_time";
$arrCita=array();
foreach($db->query($sql) as $row) {
$cita = new CitaTO();
$cita->setIdEntry($row['cal_id']);
$cita->setLogin($row['id_eje']);
$cita->setDescripcion($row['cal_description']);
$cita->setEstado($row['cal_Estado']);
$cita->setFecha($row['cal_date']);
$cita->setNombre($row['cal_name']);
$cita->setHora($this->display_hora($row['cal_time']));
//if()
$cita->setObjetivos($this->objetivosCita(array('id_cita'=>$row['cal_id'])));
$arrCita[] = $cita;
}
return $arrCita;
}catch( Exception $e){
$msg = mysql_error();
error_log($msg."\n\n", 3, "../log/error.log");
throw $e;
}
}
function display_hora($time = '') {
$hour = intval($time / 10000);
$min = abs(( $time / 100 ) % 100);
if ($time < 0 && $min > 0)
$hour--;
while ($hour < 0) {
$hour += 24;
}
while ($hour > 23) {
$hour -= 24;
}
$t_format = '12';
if ($t_format == '12') {
$hour = $hour - 5;
$ampm = $hour >= 12 ? 'pm' : 'am';
$hour %= 12;
if ($hour == 0)
$hour = 12;
$ret = sprintf("%d:%02d%s", $hour, $min, $ampm);
}
return $ret;
}
public function objetivosCita($data){
//print_r($data);
//exit;
try {
$dba=ConexionBD::getConexion();
$cita = $data['id_cita'];
// if($cita!=""){
$sql="SELECT DISTINCT ac.Desc_action FROM webcal_actions AS ac
INNER JOIN webcal_asignaaction AS aa
ON aa.id_Action = ac.id_Action
WHERE aa.cal_entry = '$cita'";
//echo $sql;
$arrAccion=array();
foreach($dba->query($sql) as $rows) {
$objAcTO = new AccionTO();
$objAcTO->setDescripcion($rows["Desc_action"]);
$arrAccion[]=$objAcTO;
}
return $arrAccion;
//}
}catch( Exception $e){
$msg = mysql_error();
error_log($msg."\n\n", 3, "../log/error.log");
throw $e;
}
}
}
Código:
Warning: Invalid argument supplied for foreach() in C:\wamp\www\WebCalendar2\model\CitaModel.php on line 94
se refiere a la linea del foreach
Código PHP:
foreach($dba->query($sql) as $rows)