Foros del Web » Programando para Internet » PHP »

problema al mostrar evento en el calendario

Estas en el tema de problema al mostrar evento en el calendario en el foro de PHP en Foros del Web. Hola amigos del foro, un abrazo a todos... 1.-Tengo una duda con un calendario mi duda es la siguiente.. Este calendario se conecta con una ...
  #1 (permalink)  
Antiguo 07/05/2012, 02:41
 
Fecha de Ingreso: mayo-2012
Ubicación: Lima
Mensajes: 14
Antigüedad: 11 años, 11 meses
Puntos: 1
Pregunta problema al mostrar evento en el calendario

Hola amigos del foro, un abrazo a todos...
1.-Tengo una duda con un calendario mi duda es la siguiente.. Este calendario se conecta con una BD y quiero mostrar los eventos que hay en mi tabla tareas y bueno aqui esta el problema pues ya hice todo lo que se me ocurre para mostrar estos eventos pero no se muestran......pero hay un detalle y es que cuando ingreso el evento manualmente en el calendario este evento si se almacena en mi BD pero no se muestran los eventos que ya existen en la tabla tareas. Quisiera que porfavor me hechen una mano para poder solucionar este problema.
2.-Tengo una segunda duda y es que quiero saber si se puede mostra los eventos de dos tablas osea tabla1.columna1,tabla2.columna2 si es asi me pueden ayuadr dandome alguna idea como puedo lograrlo.
Espero puedan ayudarme se los agradeceré bastante.
Código PHP:
<?php
include_once("dbconfig.php");
include_once(
"functions.php");

function 
addCalendar($st$et$sub$ade){
  
$ret = array();
  try{
    
$db = new DBConnection();
    
$db->getConnection();
    
$sql "insert into `tareas` (`codigo`, `fecha_inicio`, `fecha_fin`, `ing_asignado`) values ('"
      
.mysql_real_escape_string($sub)."', '"
      
.php2MySqlTime(js2PhpTime($st))."', '"
      
.php2MySqlTime(js2PhpTime($et))."', '"
      
.mysql_real_escape_string($ade)."' )";
    
//echo($sql);
        
if(mysql_query($sql)==false){
      
$ret['IsSuccess'] = false;
      
$ret['Msg'] = mysql_error();
    }else{
      
$ret['IsSuccess'] = true;
      
$ret['Msg'] = 'add success';
      
$ret['Data'] = mysql_insert_id();
    }
    }catch(
Exception $e){
     
$ret['IsSuccess'] = false;
     
$ret['Msg'] = $e->getMessage();
  }
  return 
$ret;
}


function 
addDetailedCalendar($st$et$sub$ade){
  
$ret = array();
  try{
    
$db = new DBConnection();
    
$db->getConnection();
    
$sql "insert into `tareas` (`codigo`, `fecha_inicio`, `fecha_fin`, `ing_asignado`) values ('"
      
.mysql_real_escape_string($sub)."', '"
      
.php2MySqlTime(js2PhpTime($st))."', '"
      
.php2MySqlTime(js2PhpTime($et))."', '"
      
.mysql_real_escape_string($ade)."' '";
    
//echo($sql);
        
if(mysql_query($sql)==false){
      
$ret['IsSuccess'] = false;
      
$ret['Msg'] = mysql_error();
    }else{
      
$ret['IsSuccess'] = true;
      
$ret['Msg'] = 'add success';
      
$ret['Data'] = mysql_insert_id();
    }
    }catch(
Exception $e){
     
$ret['IsSuccess'] = false;
     
$ret['Msg'] = $e->getMessage();
  }
  return 
$ret;
}

function 
listCalendarByRange($sd$ed){
  
$ret = array();
  
$ret['events'] = array();
  
$ret["issort"] =true;
  
$ret["inicio"] = php2JsTime($sd);
  
$ret["fin"] = php2JsTime($ed);
  
$ret['error'] = null;
  try{
    
$db = new DBConnection();
    
$db->getConnection();
    
$sql "select * from `tareas` where `fecha_inicio` between '"
      
.php2MySqlTime($sd)."' and '"php2MySqlTime($ed)."'";
    
$handle mysql_query($sql);
    
//echo $sql;
    
while ($row mysql_fetch_object($handle)) {
      
//$ret['events'][] = $row;
      //$attends = $row->AttendeeNames;
      //if($row->OtherAttendee){
      //  $attends .= $row->OtherAttendee;
      //}
      //echo $row->StartTime;
      
$ret['events'][] = array(
        
$row->id,
        
$row->codigo,
        
php2JsTime(mySql2PhpTime($row->fecha_inicio)),
        
php2JsTime(mySql2PhpTime($row->fecha_fin)),
        
$row->ing_asignado,
        
0//más de un día del evento
        //$row->InstanceType,
        
0,//Evento recurrente,
        
$row->Color,
        
1,//editable
        
$row->Location
        
''//$attends
      
);
    }
    }catch(
Exception $e){
     
$ret['error'] = $e->getMessage();
  }
  return 
$ret;
}

function 
listCalendar($day$type){
  
$phpTime js2PhpTime($day);
  
//echo $phpTime . "+" . $type;
  
switch($type){
    case 
"month":
      
$st mktime(000date("m"$phpTime), 1date("Y"$phpTime));
      
$et mktime(00, -1date("m"$phpTime)+11date("Y"$phpTime));
      break;
    case 
"week":
      
//Supongo que el primer día de la semana es el lunes
      
$monday  =  date("d"$phpTime) - date('N'$phpTime) + 1;
      
//echo date('N', $phpTime);
      
$st mktime(0,0,0,date("m"$phpTime), $mondaydate("Y"$phpTime));
      
$et mktime(0,0,-1,date("m"$phpTime), $monday+7date("Y"$phpTime));
      break;
    case 
"day":
      
$st mktime(000date("m"$phpTime), date("d"$phpTime), date("Y"$phpTime));
      
$et mktime(00, -1date("m"$phpTime), date("d"$phpTime)+1date("Y"$phpTime));
      break;
  }
  
//echo $st . "--" . $et;
  
return listCalendarByRange($st$et);
}

function 
updateCalendar($id$st$et){
  
$ret = array();
  try{
    
$db = new DBConnection();
    
$db->getConnection();
    
$sql "update `tareas` set"
      
" `fecha_inicio`='" php2MySqlTime(js2PhpTime($st)) . "', "
      
" `fecha_fin`='" php2MySqlTime(js2PhpTime($et)) . "' "
      
"where `id`=" $id;
    
//echo $sql;
        
if(mysql_query($sql)==false){
      
$ret['IsSuccess'] = false;
      
$ret['Msg'] = mysql_error();
    }else{
      
$ret['IsSuccess'] = true;
      
$ret['Msg'] = 'Succefully';
    }
    }catch(
Exception $e){
     
$ret['IsSuccess'] = false;
     
$ret['Msg'] = $e->getMessage();
  }
  return 
$ret;
}

function 
updateDetailedCalendar($id$st$et$sub$ade$dscr$loc$color$tz){
  
$ret = array();
  try{
    
$db = new DBConnection();
    
$db->getConnection();
    
$sql "update `tareas` set"
      
" `fecha_inicio`='" php2MySqlTime(js2PhpTime($st)) . "', "
      
" `fecha_fin`='" php2MySqlTime(js2PhpTime($et)) . "', "
      
" `codigo`='" mysql_real_escape_string($sub) . "', "
      
" `ing_asignado`='" mysql_real_escape_string($ade) . "' "
      
      
"where `id`=" $id;
    
//echo $sql;
        
if(mysql_query($sql)==false){
      
$ret['IsSuccess'] = false;
      
$ret['Msg'] = mysql_error();
    }else{
      
$ret['IsSuccess'] = true;
      
$ret['Msg'] = 'Succefully';
    }
    }catch(
Exception $e){
     
$ret['IsSuccess'] = false;
     
$ret['Msg'] = $e->getMessage();
  }
  return 
$ret;
}

function 
removeCalendar($id){
  
$ret = array();
  try{
    
$db = new DBConnection();
    
$db->getConnection();
    
$sql "delete from `tareas` where `id`=" $id;
        if(
mysql_query($sql)==false){
      
$ret['IsSuccess'] = false;
      
$ret['Msg'] = mysql_error();
    }else{
      
$ret['IsSuccess'] = true;
      
$ret['Msg'] = 'Succefully';
    }
    }catch(
Exception $e){
     
$ret['IsSuccess'] = false;
     
$ret['Msg'] = $e->getMessage();
  }
  return 
$ret;
}




header('Content-type:text/javascript;charset=UTF-8');
$method $_GET["method"];
switch (
$method) {
    case 
"add":
        
$ret addCalendar($_POST["CalendarStartTime"], $_POST["CalendarEndTime"], $_POST["CalendarTitle"], $_POST["IsAllDayEvent"]);
        break;
    case 
"list":
        
$ret listCalendar($_POST["showdate"], $_POST["viewtype"]);
        break;
    case 
"update":
        
$ret updateCalendar($_POST["calendarId"], $_POST["CalendarStartTime"], $_POST["CalendarEndTime"]);
        break; 
    case 
"remove":
        
$ret removeCalendar$_POST["calendarId"]);
        break;
    case 
"adddetails":
        
$st $_POST["stpartdate"] . " " $_POST["stparttime"];
        
$et $_POST["etpartdate"] . " " $_POST["etparttime"];
        if(isset(
$_GET["id"])){
            
$ret updateDetailedCalendar($_GET["id"], $st$et
                
$_POST["Subject"], isset($_POST["IsAllDayEvent"])?1:0$_POST["Description"], 
                
$_POST["Location"], $_POST["colorvalue"], $_POST["timezone"]);
        }else{
            
$ret addDetailedCalendar($st$et,                    
                
$_POST["Subject"], isset($_POST["IsAllDayEvent"])?1:0$_POST["Description"], 
                
$_POST["Location"], $_POST["colorvalue"], $_POST["timezone"]);
        }        
        break; 
}
echo 
json_encode($ret); 

?>
  #2 (permalink)  
Antiguo 07/05/2012, 02:57
 
Fecha de Ingreso: mayo-2012
Ubicación: Lima
Mensajes: 14
Antigüedad: 11 años, 11 meses
Puntos: 1
Respuesta: problema al mostrar evento en el calendario

lo publico asi por separado porque solo puedo digitar 10000 caracteres por tema.Este es el index

Código HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<title>	Calendario </title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 
<script type="text/javascript">
     $(document).ready(function() {     
var view="week";          
var DATA_FEED_URL = "php/datafeed.db.php";
var op = {
view: view,
theme:3,
showday: new Date(),
EditCmdhandler:Edit,
DeleteCmdhandler:Delete,
ViewCmdhandler:View,    
onWeekOrMonthToDay:wtd,
onBeforeRequestData: cal_beforerequest,
onAfterRequestData: cal_afterrequest,
onRequestDataError: cal_onerror, 
autoload:true,
url: DATA_FEED_URL + "?method=list",  
quickAddUrl: DATA_FEED_URL + "?method=add", 
quickUpdateUrl: DATA_FEED_URL + "?method=update",
quickDeleteUrl: DATA_FEED_URL + "?method=remove"        
 };
var $dv = $("#calhead");
var _MH = document.documentElement.clientHeight;
var dvH = $dv.height() + 2;
op.height = _MH - dvH;
op.eventItems =[];
var p = $("#gridcontainer").bcalendar(op).BcalGetOp();
  if (p && p.datestrshow) {
       $("#txtdatetimeshow").text(p.datestrshow);
    }
    $("#caltoolbar").noSelect();
            
     $("#hdtxtshow").datepicker({ picker: "#txtdatetimeshow", showtarget: $("#txtdatetimeshow"),
  onReturn:function(r){                          
   var p = $("#gridcontainer").gotoDate(r).BcalGetOp();
      if (p && p.datestrshow) {
     $("#txtdatetimeshow").text(p.datestrshow);
     }
  } 
});
   function cal_beforerequest(type)
  {
   var t="Loading data...";
    switch(type)
   {
   case 1:
     t="Loading data...";
        break;
   case 2:                      
   case 3:  
  case 4:    
 t="Procesando ...";                                   
  break;
  }
 $("#errorpannel").hide();
  $("#loadingpannel").html(t).show();    
  }
  function cal_afterrequest(type)
 {
   switch(type)
  {
   case 1:
   $("#loadingpannel").hide();
     break;
 case 2:
 case 3:
 case 4:
   $("#loadingpannel").html("Hecho!");
                        window.setTimeout(function(){ $("#loadingpannel").hide();},2000);
 break;
  }              
}
 function cal_onerror(type,data)
 {
 $("#errorpannel").show();
    }
    function Edit(data)
     {
               var eurl="edit.php?id={0}&start={2}&end={3}&isallday={4}&title={1}";   
  if(data)
   {
       var url = StrFormat(eurl,data);
                    OpenModelWindow(url,{ width: 600, height: 400, caption:"Manage  The Calendar",onclose:function(){
                       $("#gridcontainer").reload();
       }});
    }
}    
 function View(data)
  {
    var str = "";
     $.each(data, function(i, item){
      str += "[" + i + "]: " + item + "\n";
      });
     alert(str);               
  }
  function Delete(data,callback)
   {
      $.alerts.okButton="Ok";  
      $.alerts.cancelButton="Cancel";  
      hiConfirm("Are You Sure to Delete this Event", 'Confirm',function(r){ r && callback(0);});           
            }
   function wtd(p)
     {
    if (p && p.datestrshow) {
        $("#txtdatetimeshow").text(p.datestrshow);
     }
     $("#caltoolbar div.fcurrent").each(function() {
     $(this).removeClass("fcurrent");
  })
     $("#showdaybtn").addClass("fcurrent");
   }
 //to show day view
   $("#showdaybtn").click(function(e) {
     //document.location.href="#day";
     $("#caltoolbar div.fcurrent").each(function() {
     $(this).removeClass("fcurrent");
     })
     $(this).addClass("fcurrent");
   var p = $("#gridcontainer").swtichView("day").BcalGetOp();
    if (p && p.datestrshow) {
     $("#txtdatetimeshow").text(p.datestrshow);
       }
        });
  //to show week view
  $("#showweekbtn").click(function(e) {
   //document.location.href="#week";
      $("#caltoolbar div.fcurrent").each(function() {
       $(this).removeClass("fcurrent");
        })
   $(this).addClass("fcurrent");
     var p = $("#gridcontainer").swtichView("week").BcalGetOp();
      if (p && p.datestrshow) {
       $("#txtdatetimeshow").text(p.datestrshow);
      }
    });
      //to show month view
      $("#showmonthbtn").click(function(e) {
       //document.location.href="#month";
       $("#caltoolbar div.fcurrent").each(function() {
        $(this).removeClass("fcurrent");
      })
       $(this).addClass("fcurrent");
      var p = $("#gridcontainer").swtichView("month").BcalGetOp();
      if (p && p.datestrshow) {
         $("#txtdatetimeshow").text(p.datestrshow);
       }
   });
   $("#showreflashbtn").click(function(e){
       $("#gridcontainer").reload();
            });
            //Add a new event
            $("#faddbtn").click(function(e) {
                var url ="edit.php";
                OpenModelWindow(url,{ width: 500, height: 400, caption: "Crear nuevo calendario"});
            });
            //go to today
            $("#showtodaybtn").click(function(e) {
                var p = $("#gridcontainer").gotoDate().BcalGetOp();
                if (p && p.datestrshow) {
                    $("#txtdatetimeshow").text(p.datestrshow);
                }
            });
            //previous date range
            $("#sfprevbtn").click(function(e) {
                var p = $("#gridcontainer").previousRange().BcalGetOp();
                if (p && p.datestrshow) {
                    $("#txtdatetimeshow").text(p.datestrshow);
                }
            });
            //next date range
            $("#sfnextbtn").click(function(e) {
                var p = $("#gridcontainer").nextRange().BcalGetOp();
                if (p && p.datestrshow) {
                    $("#txtdatetimeshow").text(p.datestrshow);
                }
            });
        });
    </script>    
</head>
<body>
    <div>
      <div id="calhead" style="padding-left:1px;padding-right:1px;">          
            <div class="cHead"><div class="ftitle">Calendario MG</div>
            <div id="loadingpannel" class="ptogtitle loadicon" style="display: none;">Cargando datos...</div>
             <div id="errorpannel" class="ptogtitle loaderror" style="display: none;">Disculpe, no se pudo cargar la informacion, porfavor intente mas tarde</div>
       </div>          
      <div id="caltoolbar" class="ctoolbar">
	<?php
	/*
         <div id="faddbtn" class="fbutton">
       <div><span title='Click para crear nuevo evento' class="addcal">
          Nuevo evento                
        </span></div>
      </div>
			*/
	?>
      <div class="btnseparator"></div>
      <div id="showtodaybtn" class="fbutton">
                <div><span title='Haga clic para volver al día de hoy' class="showtoday">
           Hoy</span></div>
          </div>
          <div class="btnseparator"></div>
         <div id="showdaybtn" class="fbutton">
           <div><span title=' Ver Dia' class="showdayview">Dia</span></div>
         </div>
      <div  id="showweekbtn" class="fbutton fcurrent">
                <div><span title='Ver Semana' class="showweekview">Semana</span></div>
       </div>
      <div  id="showmonthbtn" class="fbutton">
          <div><span title='Ver Mes' class="showmonthview">Mes</span></div>
         </div>
        <div class="btnseparator"></div>
          <div  id="showreflashbtn" class="fbutton">
         <div><span title='Actualizar' class="showdayflash">Refrescar</span></div>
    </div>
     <div class="btnseparator"></div>
     <div id="sfprevbtn" title="Atras"  class="fbutton">
      <span class="fprev"></span>
     </div>
      <div id="sfnextbtn" title="Siguiente" class="fbutton">
       <span class="fnext"></span>
       </div>
     <div class="fshowdatep fbutton">
     <div>
          <input type="hidden" name="txtshow" id="hdtxtshow" />
           <span id="txtdatetimeshow">Cargando</span>
     </div>
            </div>
            <div class="clear"></div>
            </div>
      </div>
      <div style="padding:1px;">

        <div class="t1 chromeColor">
            &nbsp;</div>
        <div class="t2 chromeColor">
            &nbsp;</div>
        <div id="dvCalMain" class="calmain printborder">
            <div id="gridcontainer" style="overflow-y: visible;">
            </div>
        </div>
        <div class="t2 chromeColor">
            &nbsp;</div>
        <div class="t1 chromeColor">
            &nbsp;
        </div>   
        </div>
  </div> 
</body>
</html> 
  #3 (permalink)  
Antiguo 07/05/2012, 14:03
 
Fecha de Ingreso: mayo-2012
Ubicación: Lima
Mensajes: 14
Antigüedad: 11 años, 11 meses
Puntos: 1
Respuesta: problema al mostrar evento en el calendario

Hola amigos ya econtre el problema y ahora si puedo mostrar los eventos de mi tabla con colores por cada tarea... sin embargo tengo tra duda quiero realizar la consulta desde mas de una tabla osea tabla1.columna1,tabla2.columna2 si alguien puede ayudarme a realizar esto que me de alguna idea. Gracias

Etiquetas: calendario, evento, mysql, sql, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:29.