Esempio n. 1
0
 function __construct($month = null, $year = null)
 {
     $this->month = $month | date('n');
     $this->year = $year | date('Y');
     $this->dim = cal_days_in_month(CAL_GREGORIAN, $this->month, $this->year);
     $this->msw = jddayofweek(cal_to_jd(CAL_GREGORIAN, $this->month, 1, $this->year));
 }
 private function incrementViewCount($id)
 {
     $this->Post->updateAll(array('Post.viewed' => 'Post.viewed+1'), array('Post.id' => $id));
     $this->loadModel('PostTrend');
     $day = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m"), date("d"), date("Y")), 1);
     $this->PostTrend->updateAll(array('PostTrend.' . $day => 'PostTrend.' . $day . '+1'), array('PostTrend.post_id' => $id));
 }
Esempio n. 3
0
 function getweekday($params)
 {
     $params_thang_nam = explode('/', $params);
     $params = $params_thang_nam[0];
     $thang = $params_thang_nam[1];
     $nam = $params_thang_nam[2];
     $jd = cal_to_jd(CAL_GREGORIAN, $thang, $params, $nam);
     $day = jddayofweek($jd, 0);
     switch ($day) {
         case 0:
             $thu = "Chủ nhật";
             break;
         case 1:
             $thu = "Thứ hai";
             break;
         case 2:
             $thu = "Thứ ba";
             break;
         case 3:
             $thu = "Thứ tư";
             break;
         case 4:
             $thu = "Thứ năm";
             break;
         case 5:
             $thu = "Thứ sáu";
             break;
         case 6:
             $thu = "Thứ bảy";
             break;
     }
     return $thu;
 }
 /**
  * Get Julian date value and return it as Gregorian date
  *
  * @param string $dateValue
  *
  * @return string|null Value compatible with xsd:dateTime type, null if we failed to parse
  */
 private function julianDateValue($dateValue)
 {
     try {
         list($minus, $y, $m, $d, $time) = $this->parseDateValue($dateValue);
     } catch (IllegalValueException $e) {
         return null;
     }
     // We accept here certain precision loss since we will need to do calculations anyway,
     // and we can't calculate with dates that don't fit in int.
     $y = $minus ? -(int) $y : (int) $y;
     // cal_to_jd needs int year
     // If it's too small it's fine, we'll get 0
     // If it's too big, it doesn't make sense anyway,
     // since who uses Julian with day precision in year 2 billion?
     $jd = cal_to_jd(CAL_JULIAN, $m, $d, (int) $y);
     if ($jd == 0) {
         // that means the date is broken
         return null;
     }
     // PHP API for Julian/Gregorian conversions is kind of awful
     list($m, $d, $y) = explode('/', jdtogregorian($jd));
     if ($this->xsd11 && $y < 0) {
         // To make year match XSD 1.1 we need to bump up the negative years by 1
         // We know we have precision here since otherwise we wouldn't convert
         $y++;
     }
     // This is a bit weird since xsd:dateTime requires >=4 digit always,
     // and leading 0 is not allowed for 5 digits, but sprintf counts - as digit
     // See: http://www.w3.org/TR/xmlschema-2/#dateTime
     return sprintf('%s%04d-%02d-%02dT%s', $y < 0 ? '-' : '', abs($y), $m, $d, $time);
 }
 function getWeekday($user_input)
 {
     //Converts user input to array
     $date = explode("/", $user_input);
     //Insert array to appropriate are to format to julian day
     $jul_date = cal_to_jd(CAL_GREGORIAN, (int) $date[0], (int) $date[1], (int) $date[2]);
     //Whats the date?
     $output = jddayofweek($jul_date, 1);
     return $output;
 }
Esempio n. 6
0
 function GregorianToHijri($time = null)
 {
     if ($time === null) {
         $time = time();
     }
     $m = date('m', $time);
     $d = date('d', $time);
     $y = date('Y', $time);
     return HijriCalendar::JDToHijri(cal_to_jd(CAL_GREGORIAN, $m, $d, $y));
 }
Esempio n. 7
0
 function formatDate($greg_date)
 {
     $greg_array = explode("-", $greg_date);
     $int_array = array();
     foreach ($greg_array as $token) {
         array_push($int_array, (int) $token);
     }
     if ($int_array[2] == 0 || $int_array[1] == 0 || $int_array[0] == 0) {
         return 0;
     }
     return cal_to_jd(CAL_GREGORIAN, $int_array[1], $int_array[2], $int_array[0]);
 }
 public function executeCargarReservaciones(sfWebRequest $request)
 {
     date_default_timezone_set("America/Guayaquil");
     $dia = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m"), date("d"), date("Y")), 0);
     //        $tDesde=time()-600;
     //        $tHasta=time()-540;
     //        $hDesde=date('H:i:s',$tDesde);
     //        $hHasta=date('H:i:s',$tHasta);
     switch ($dia) {
         case '1':
             $reservacion = Doctrine_Core::getTable('reservacion')->createQuery('c')->where('c.lunes=?', true)->execute();
             break;
         case '2':
             $reservacion = Doctrine_Core::getTable('reservacion')->createQuery('c')->where('c.martes=?', true)->execute();
             break;
         case '3':
             $reservacion = Doctrine_Core::getTable('reservacion')->createQuery('c')->where('c.miercoles=?', true)->execute();
             break;
         case '4':
             $reservacion = Doctrine_Core::getTable('reservacion')->createQuery('c')->where('c.jueves=?', true)->execute();
             break;
         case '5':
             $reservacion = Doctrine_Core::getTable('reservacion')->createQuery('c')->where('c.viernes=?', true)->execute();
             break;
         case '6':
             $reservacion = Doctrine_Core::getTable('reservacion')->createQuery('c')->where('c.sabado=?', true)->execute();
             break;
         case '0':
             $reservacion = Doctrine_Core::getTable('reservacion')->createQuery('c')->where('c.domingo=?', true)->execute();
             break;
         default:
             break;
     }
     $dataJson = array();
     foreach ($reservacion as $reser) {
         if ($reser->getHorario1()) {
             if (Operaciones::esHoraReservacion($reser->getHorario1(), date('H:i:s'))) {
                 $dataJson[] = array('id' => $reser->getId(), 'barrio' => $reser->getCodigo()->getSector()->getNombre(), 'calle1' => $reser->getCodigo()->getCalle1(), 'calle2' => $reser->getCodigo()->getCalle2(), 'cliente' => $reser->getCodigo()->getNombreCliente(), 'hora' => $reser->getHorario1(), 'codigo' => $reser->getCodigo()->getNumero(), 'idcodigo' => $reser->getCodigo()->getId(), 'idsector' => $reser->getCodigo()->getBarrio(), 'latitud' => $reser->getCodigo()->getLatitud(), 'longitud' => $reser->getCodigo()->getLongitud(), 'referencia' => $reser->getCodigo()->getObservacion());
             }
         }
         if ($reser->getHorario2()) {
             if (Operaciones::esHoraReservacion($reser->getHorario2(), date('H:i:s'))) {
                 $dataJson[] = array('id' => $reser->getId(), 'barrio' => $reser->getCodigo()->getSector()->getNombre(), 'calle1' => $reser->getCodigo()->getCalle1(), 'calle2' => $reser->getCodigo()->getCalle2(), 'cliente' => $reser->getCodigo()->getNombreCliente(), 'hora' => $reser->getHorario2(), 'codigo' => $reser->getCodigo()->getNumero(), 'idcodigo' => $reser->getCodigo()->getId(), 'idsector' => $reser->getCodigo()->getBarrio(), 'latitud' => $reser->getCodigo()->getLatitud(), 'longitud' => $reser->getCodigo()->getLongitud(), 'referencia' => $reser->getCodigo()->getObservacion());
             }
         }
         if ($reser->getHorario3()) {
             if (Operaciones::esHoraReservacion($reser->getHorario3(), date('H:i:s'))) {
                 $dataJson[] = array('id' => $reser->getId(), 'barrio' => $reser->getCodigo()->getSector()->getNombre(), 'calle1' => $reser->getCodigo()->getCalle1(), 'calle2' => $reser->getCodigo()->getCalle2(), 'cliente' => $reser->getCodigo()->getNombreCliente(), 'hora' => $reser->getHorario3(), 'codigo' => $reser->getCodigo()->getNumero(), 'idcodigo' => $reser->getCodigo()->getId(), 'idsector' => $reser->getCodigo()->getBarrio(), 'latitud' => $reser->getCodigo()->getLatitud(), 'longitud' => $reser->getCodigo()->getLongitud(), 'referencia' => $reser->getCodigo()->getObservacion());
             }
         }
     }
     return $this->renderText(json_encode($dataJson));
 }
Esempio n. 9
0
 function checkCalendar($date)
 {
     //Explodes input string into array.
     $straight_date = explode('-', $date);
     //Converts array into Julian Day number.
     $jd_date = cal_to_jd(CAL_GREGORIAN, $straight_date[1], $straight_date[2], $straight_date[0]);
     //Converts Julian Day into day of week.
     $day_of_week = jddayofweek($jd_date, 1);
     if ($day_of_week == "Monday") {
         return $day_of_week . "; that sucks!";
     } else {
         return $day_of_week;
     }
 }
 public static function buscarPromo($codigo_plan)
 {
     $fecha_compra = Formatos::fechaHoraActual();
     $codigo_comercio = Persona::numeroComercio();
     $dia_semana = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m"), date("d"), date("Y")));
     $empresa = 1;
     $sucursal = 1;
     $sql = "\n\t\t\t\tSELECT TOP 1\n\t\t\t\t\t tarjetas_planes_promocion.nombre_plan as nombre,\n\t\t\t\t\t tarjetas_planes_promocion.vigencia_hasta as vencimiento\n\t\t\t\t  FROM tarjetas_planes_promocion\n\t\t\t\t WHERE nro_empresa  = {$empresa}\n\t\t\t\t\tAND nro_sucursal = {$sucursal}\n\t\t\t\t\tAND tarjetas_planes_promocion.codigo_plan = {$codigo_plan}\n\t\t\t\t\tAND Isnull( comercios_todos, 0 )  = 1\n\t\t\t\t\tAND (( IsNull( domingo\t, 0 ) \t= 1 AND 1 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( lunes\t, 0 ) \t= 1 AND 2 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( martes\t, 0 ) \t= 1 AND 3 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( miercoles, 0 ) \t= 1 AND 4 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( jueves\t, 0 ) \t= 1 AND 5 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( viernes\t, 0 ) \t= 1 AND 6 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( sabado\t, 0 ) \t= 1 AND 7 = {$dia_semana} ) ) \n\t\t\t\t\tAND vigencia_desde <= '{$fecha_compra}'\n\t\t\t\t\tAND vigencia_hasta >= '{$fecha_compra}'\n\t\t\t\t\tAND isnull(habilitado,0) = 1\n\n\t\t\t\tUNION ALL\n\n\t\t\t\tSELECT\n\t\t\t\t\t tarjetas_planes_promocion.nombre_plan AS nombre,\n\t\t\t\t\t tarjetas_planes_promocion.vigencia_hasta AS vencimiento\n\n\t\t\t\t  FROM tarjetas_planes_comercios\n\t\t\t\t  JOIN tarjetas_planes_promocion ON\n\t\t\t\t\t\t( tarjetas_planes_comercios.nro_empresa  \t  =  tarjetas_planes_promocion.nro_empresa AND\n\t\t\t\t\t\t  tarjetas_planes_comercios.nro_sucursal \t  =  tarjetas_planes_promocion.nro_sucursal \t AND\n\t\t\t\t\t\t  tarjetas_planes_comercios.codigo_plan  \t  =  tarjetas_planes_promocion.codigo_plan  \t AND\n\t\t\t\t\t\t  tarjetas_planes_comercios.vigencia_desde  =  tarjetas_planes_promocion.vigencia_desde AND\n\t\t\t\t\t\t  tarjetas_planes_comercios.cod_promocion\t  =  tarjetas_planes_promocion.cod_promocion\t )\n\n\t\t\t\t WHERE tarjetas_planes_comercios.nro_empresa  \t\t= {$empresa}\n\t\t\t\t\tAND tarjetas_planes_comercios.nro_sucursal \t\t= {$sucursal}\n\t\t\t\t\tAND tarjetas_planes_comercios.codigo_comercio \t= {$codigo_comercio}\n\n\t\t\t\t\tAND tarjetas_planes_comercios.codigo_plan \t\t= {$codigo_plan}\n\t\t\t\t\tAND (( IsNull( tarjetas_planes_promocion.domingo\t, 0 ) = 1 AND 1 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( tarjetas_planes_promocion.lunes\t\t, 0 ) = 1 AND 2 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( tarjetas_planes_promocion.martes\t, 0 ) = 1 AND 3 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( tarjetas_planes_promocion.miercoles\t, 0 ) = 1 AND 4 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( tarjetas_planes_promocion.jueves\t, 0 ) = 1 AND 5 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( tarjetas_planes_promocion.viernes\t, 0 ) = 1 AND 6 = {$dia_semana} ) or \n\t\t\t\t\t\t  ( IsNull( tarjetas_planes_promocion.sabado\t, 0 ) = 1 AND 7 = {$dia_semana} ) ) \n\n\t\t\t\t\tAND tarjetas_planes_comercios.vigencia_desde <= '{$fecha_compra}'\n\t\t\t\t\tAND tarjetas_planes_comercios.vigencia_hasta >= '{$fecha_compra}'\n\t\t\t\t\tAND isnull(tarjetas_planes_comercios.habilitado,0) = 1\n\t\t\t\t    AND isnull(tarjetas_planes_promocion.habilitado,0) = 1\n\t\t";
     $datos = DB::select($sql);
     if (count($datos) <= 0) {
         return 'no hay';
     }
     return $datos;
 }
Esempio n. 11
0
    public function contains(\DateTime $dateTime)
    {
        $value = ($this->day < 0) ? -1 : 1;

        $compare = clone $dateTime();

        $dayOfWeek = jddayofweek(cal_to_jd(CAL_GREGORIAN,
                                           $dateTime->format('m'),
                                           $dateTime->format('j'),
                                           $dateTime->format('Y')));

        return ($this->day == $dayOfWeek) &&
            ($compare->add((-1 * $this->day) . ' days')->format('m') != $dateTime->format('m')) &&
            ($compare->setDate($dateTime->getTimestamp())->add((-1 * $this->day) + $value)->format('m') == $dateTime->format('m'));
    }
 public function contains(\DateTime $dateTime)
 {
     if ($this->ignoreDay) {
         if ($this->day > 0) {
             return $dateTime->format('j') == $this->day;
         } else {
             $calendarDays = cal_days_in_month(CAL_GREGORIAN, $dateTime->format('Y'), $dateTime->format('m'));
             return $calendarDays + 1 + $this->day === $dateTime->format('j');
         }
     } else {
         $value = $this->day < 0 ? -1 : 1;
         $compare = clone $dateTime();
         $dayOfWeek = jddayofweek(cal_to_jd(CAL_GREGORIAN, $dateTime->format('m'), $dateTime->format('j'), $dateTime->format('Y')));
         return $this->day == $dayOfWeek && $compare->add(-1 * $this->day . ' days')->format('m') != $dateTime->format('m') && $compare->setDate($dateTime->getTimestamp())->add(-1 * $this->day + $value)->format('m') == $dateTime->format('m');
     }
 }
 public function index()
 {
     $year = date("Y", time());
     $month = date("n", time());
     $day = date("j", time());
     $noOfThisWeek = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m"), date("d"), date("Y")), 0);
     if ($noOfThisWeek == 0) {
         $noOfThisWeek = 7;
     }
     $plus = 7 - $numOfday;
     $by = $noOfThisWeek - 1;
     $today_beginSec = mktime(0, 0, 0, $month, $day, $year);
     $today_lastSec = mktime(24, 0, 0, $month, $day, $year);
     $yestday_beginSec = mktime(0, 0, 0, $month, $day - 1, $year);
     $yestday_lastSec = mktime(24, 0, 0, $month, $day - 1, $year);
     $this_week_beginSec = mktime(0, 0, 0, $month, $day - $by, $year);
     $this_week_endSec = mktime(24, 0, 0, $month, $day + $plus, $year);
     $this_month_beginSec = mktime(0, 0, 0, $month, 1, $year);
     $this_month_endSec = mktime(0, 0, 0, $month + 1, 1, $year);
     $this_year_beginSec = mktime(0, 0, 0, 1, 1, $year);
     $this_year_endSec = mktime(0, 0, 0, 1, 1, $year + 1);
     $Inqueue = M("Inqueue");
     $Okin = M("Okin");
     $results_inqueue = $Inqueue->select();
     $results_okin_today = $Okin->where("`out_time` > {$today_beginSec} AND `out_time` < {$today_lastSec}")->select();
     $results_okin_yestoday = $Okin->where("`out_time` > {$yestday_beginSec} AND `out_time` < {$yestday_lastSec}")->select();
     $results_okin_this_week = $Okin->field('user_numb,user_name,sum(delay_time),avg(delay_time),count(user_numb)')->group('user_numb')->where("`out_time` > {$this_week_beginSec} AND `out_time` < {$this_week_endSec}")->select();
     $results_okin_this_month = $Okin->field('user_numb,user_name,sum(delay_time),avg(delay_time),count(user_numb)')->group('user_numb')->where("`out_time` > {$this_month_beginSec} AND `out_time` < {$this_month_endSec}")->select();
     $results_okin_this_year = $Okin->field('user_numb,user_name,sum(delay_time),avg(delay_time),count(user_numb)')->group('user_numb')->where("`out_time` > {$this_year_beginSec} AND `out_time` < {$this_year_endSec}")->select();
     //var_dump($results_okin_this_month);
     $this->assign('title', '签到统计');
     $this->assign('results_inqueue', $results_inqueue);
     $this->assign('results_okin_today', $results_okin_today);
     $this->assign('results_okin_yestoday', $results_okin_yestoday);
     $this->assign('results_okin_this_week', $results_okin_this_week);
     $this->assign('results_okin_this_month', $results_okin_this_month);
     $this->assign('results_okin_this_year', $results_okin_this_year);
     $this->display('index');
 }
 public function loadHolidays()
 {
     $jdDate = cal_to_jd(CAL_GREGORIAN, date('m'), date('d'), date('Y'));
     $hebrewDate = jdtojewish($jdDate);
     list($hebrewMonth, $hebrewDay, $hebrewYear) = explode('/', $hebrewDate);
     $holidays = array();
     $currYear = $hebrewYear - 1;
     // subtract a year for some reason
     $nextYear = $currYear + 1;
     foreach ($this->holidays as $key => $val) {
         $julianDate = jewishtojd($val[0], $val[1], $currYear);
         if (jdtounix($julianDate) < time()) {
             $julianDate = jewishtojd($val[0], $val[1], $nextYear);
             if (jdtounix($julianDate) < time()) {
                 $julianDate = jewishtojd($val[0], $val[1], $nextYear + 1);
             }
         }
         $unixTime = jdtounix($julianDate);
         $unixTime += 86400;
         // add 1 day for some reason
         $holidays[$key] = '@' . $unixTime;
     }
     return $holidays;
 }
Esempio n. 15
0
     if ($adate['mon'] > 12) {
         $adate['year'] += 1;
         $adate['mon'] -= 12;
     }
     if ($my_repeat_on_num < 5) {
         // not last
         $adate['mday'] = 1;
         $dow = jddayofweek(cal_to_jd(CAL_GREGORIAN, $adate['mon'], $adate['mday'], $adate['year']));
         if ($dow > $my_repeat_on_day) {
             $dow -= 7;
         }
         $adate['mday'] += ($my_repeat_on_num - 1) * 7 + $my_repeat_on_day - $dow;
     } else {
         // last weekday of month
         $adate['mday'] = cal_days_in_month(CAL_GREGORIAN, $adate['mon'], $adate['year']);
         $dow = jddayofweek(cal_to_jd(CAL_GREGORIAN, $adate['mon'], $adate['mday'], $adate['year']));
         if ($dow < $my_repeat_on_day) {
             $dow += 7;
         }
         $adate['mday'] += $my_repeat_on_day - $dow;
     }
 } else {
     // recurrtype 1
     if ($repeattype == 0) {
         // daily
         $adate['mday'] += 1;
     } else {
         if ($repeattype == 1) {
             // weekly
             $adate['mday'] += 7;
         } else {
Esempio n. 16
0
function getRecurringEvents($event, $from_date, $to_date)
{
    $repeatEvents = array();
    $from_date_time = strtotime($from_date . " 00:00:00");
    $thistime = strtotime($event['pc_eventDate'] . " 00:00:00");
    //$thistime = max( $thistime, $from_date_time );
    if ($event['pc_recurrtype']) {
        preg_match('/"event_repeat_freq_type";s:1:"(\\d)"/', $event['pc_recurrspec'], $matches);
        $repeattype = $matches[1];
        preg_match('/"event_repeat_freq";s:1:"(\\d)"/', $event['pc_recurrspec'], $matches);
        $repeatfreq = $matches[1];
        if ($event['pc_recurrtype'] == 2) {
            // Repeat type is 2 so frequency comes from event_repeat_on_freq.
            preg_match('/"event_repeat_on_freq";s:1:"(\\d)"/', $event['pc_recurrspec'], $matches);
            $repeatfreq = $matches[1];
        }
        if (!$repeatfreq) {
            $repeatfreq = 1;
        }
        preg_match('/"event_repeat_on_num";s:1:"(\\d)"/', $event['pc_recurrspec'], $matches);
        $my_repeat_on_num = $matches[1];
        preg_match('/"event_repeat_on_day";s:1:"(\\d)"/', $event['pc_recurrspec'], $matches);
        $my_repeat_on_day = $matches[1];
        $upToDate = strtotime($to_date . " 23:59:59");
        // set the up-to-date to the last second of the "to_date"
        $endtime = strtotime($event['pc_endDate'] . " 23:59:59");
        if ($endtime > $upToDate) {
            $endtime = $upToDate;
        }
        $repeatix = 0;
        while ($thistime < $endtime) {
            // Skip the event if a repeat frequency > 1 was specified and this is
            // not the desired occurrence.
            if (!$repeatix) {
                $inRange = $thistime >= $from_date_time && $thistime < $upToDate;
                if ($inRange) {
                    $newEvent = $event;
                    $eventDate = date("Y-m-d", $thistime);
                    $newEvent['pc_eventDate'] = $eventDate;
                    $newEvent['pc_endDate'] = $eventDate;
                    $repeatEvents[] = $newEvent;
                }
            }
            if (++$repeatix >= $repeatfreq) {
                $repeatix = 0;
            }
            $adate = getdate($thistime);
            if ($event['pc_recurrtype'] == 2) {
                // Need to skip to nth or last weekday of the next month.
                $adate['mon'] += 1;
                if ($adate['mon'] > 12) {
                    $adate['year'] += 1;
                    $adate['mon'] -= 12;
                }
                if ($my_repeat_on_num < 5) {
                    // not last
                    $adate['mday'] = 1;
                    $dow = jddayofweek(cal_to_jd(CAL_GREGORIAN, $adate['mon'], $adate['mday'], $adate['year']));
                    if ($dow > $my_repeat_on_day) {
                        $dow -= 7;
                    }
                    $adate['mday'] += ($my_repeat_on_num - 1) * 7 + $my_repeat_on_day - $dow;
                } else {
                    // last weekday of month
                    $adate['mday'] = cal_days_in_month(CAL_GREGORIAN, $adate['mon'], $adate['year']);
                    $dow = jddayofweek(cal_to_jd(CAL_GREGORIAN, $adate['mon'], $adate['mday'], $adate['year']));
                    if ($dow < $my_repeat_on_day) {
                        $dow += 7;
                    }
                    $adate['mday'] += $my_repeat_on_day - $dow;
                }
            } else {
                // recurrtype 1
                if ($repeattype == 0) {
                    // daily
                    $adate['mday'] += 1;
                } else {
                    if ($repeattype == 1) {
                        // weekly
                        $adate['mday'] += 7;
                    } else {
                        if ($repeattype == 2) {
                            // monthly
                            $adate['mon'] += 1;
                        } else {
                            if ($repeattype == 3) {
                                // yearly
                                $adate['year'] += 1;
                            } else {
                                if ($repeattype == 4) {
                                    // work days
                                    if ($adate['wday'] == 5) {
                                        // if friday, skip to monday
                                        $adate['mday'] += 3;
                                    } else {
                                        if ($adate['wday'] == 6) {
                                            // saturday should not happen
                                            $adate['mday'] += 2;
                                        } else {
                                            $adate['mday'] += 1;
                                        }
                                    }
                                } else {
                                    die("Invalid repeat type '{$repeattype}'");
                                }
                            }
                        }
                    }
                }
            }
            // end recurrtype 1
            $thistime = mktime(0, 0, 0, $adate['mon'], $adate['mday'], $adate['year']);
        }
    }
    return $repeatEvents;
}
Esempio n. 17
0
<?php

$nombre = "ayer.html";
$ayer = mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"));
$today = date('Ymd', $ayer);
$dayweek = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m"), date("d") - 1, date("Y")), 0);
include 'include.php';
?>
 
Esempio n. 18
0
 public function onLoad($param)
 {
     parent::onLoad($param);
     $idSolicitud = $_REQUEST['id'];
     $this->dbConexion = Conexion::getConexion($this->Application, "dbpr");
     Conexion::createConfiguracion();
     $consulta = "SELECT s.id_solicitud as solicitud,s.titular as titularr ,s.antiguedad as antiguedad,DATE_FORMAT(t.fec_ingre,'%Y/%m/%d') AS creada,t.numero AS num_tit, t.nombre AS titular, st.cve_sindicato AS tit_cve_sind, st.sindicato AS tit_sind, TIMESTAMPDIFF(YEAR, t.fec_ingre, CURDATE()) AS tit_ant,\n\t\t\t\t\taval1, a1.nombre AS aval1_n, sa1.cve_sindicato AS aval1_cve_sind, sa1.sindicato AS aval1_sind, TIMESTAMPDIFF(YEAR, a1.fec_ingre, CURDATE()) AS aval1_ant,\n\t\t\t\t\taval2, a2.nombre AS aval2_n, sa2.cve_sindicato AS aval2_cve_sind, sa2.sindicato AS aval2_sind, TIMESTAMPDIFF(YEAR, a2.fec_ingre, CURDATE()) AS aval2_ant,\n\t\t\t\t\t(SELECT representante FROM CATSINDICATOS WHERE cve_sindicato = tit_cve_sind) as SindicatoRpre\n\t\t\t\t\t,DATE_FORMAT(s.firma,'%d/%m/%Y') AS firma, importe, plazo, tasa, saldo_anterior, descuento\n\t\t\t\t\t,(SELECT CASE tipo_nomi\n              WHEN tipo_nomi = 'S' THEN 'SEMANAL' \n              WHEN tipo_nomi = 'Q' THEN 'QUINCENAL'\n              ELSE 'NO HAY TIPO DE NOMINA' END AS mesto_utovara\n\t\t\tFROM empleados WHERE numero = s.titular) as TipoNominaTit\n\t\t\t\t\t\n\t\tFROM Solicitud s \n\t\tLEFT JOIN sujetos AS t ON t.numero = s.titular\n\t\tLEFT JOIN catsindicatos st ON st.cve_sindicato = s.cve_sindicato\n\t\tLEFT JOIN sujetos AS a1 ON a1.numero= s.aval1\n\t\tLEFT JOIN catsindicatos sa1 ON sa1.cve_sindicato = s.cve_sind_Aval1\n\t\tLEFT JOIN sujetos AS a2 ON a2.numero = s.aval2\n\t\tLEFT JOIN catsindicatos sa2 ON sa2.cve_sindicato = s.cve_sind_Aval2\n\t\tWHERE s.id_solicitud = (SELECT MAX(id_solicitud) AS id_solicitud FROM Solicitud WHERE  titular = :idSolicitud)";
     $comando = $this->dbConexion->createCommand($consulta);
     $comando->bindValue(":idSolicitud", $idSolicitud);
     $result = $comando->query()->readAll();
     foreach ($result as $rows) {
         $VarSolicitante = $rows['solicitud'];
         $VarClaveSindicato = $rows['tit_cve_sind'];
         $VarRepreSindicato = $rows['SindicatoRpre'];
         $Solicitud = $rows['titular'];
         $VarSolicitud = $rows['titularr'];
         $VarFechadeIngreso = $rows['creada'];
         $VarAntiguedad = $rows['antiguedad'];
         $VarSindicato = $rows['tit_sind'];
         $VarFirmAvales = $rows['firma'];
         $Aval1 = $rows['aval1'];
         $Aval2 = $rows['aval2'];
         $VarAval1 = $rows['aval1_n'];
         $VarAval2 = $rows['aval2_n'];
         $VarPlazo = $rows['plazo'];
         $Importe = $rows['importe'];
         $creada = $rows['creada'];
         $TipoNomina = $rows['TipoNominaTit'];
     }
     $VarImporte = number_format($Importe, 2);
     $mes = date("n");
     $meses = 11 - $mes;
     $consultaDirec = "SELECT Nombre_completo FROM cat_director WHERE anio = YEAR(NOW())";
     $comando = $this->dbConexion->createCommand($consultaDirec);
     $result = $comando->query()->readAll();
     foreach ($result as $rows) {
         $VarDirector = $rows['Nombre_completo'];
     }
     $fecha = date('Y/m/j');
     $i = strtotime($fecha);
     $dia = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m", $i), date("d", $i), date("Y", $i)), 0);
     if ($dia >= 4) {
         $nuevafecha = strtotime('+4 day', strtotime($fecha));
         $nuevafecha = date('j/m/Y', $nuevafecha);
     } else {
         $nuevafecha = strtotime('+1 day', strtotime($fecha));
         $nuevafecha = date('j/m/Y', $nuevafecha);
     }
     $datetime1 = date_create($creada);
     $datetime2 = date_create($fecha);
     $AntLetras = date_diff($datetime1, $datetime2);
     $AntLetra = $AntLetras->format('%Y Años %m Meses %d Dias');
     $hoy = date("Y-m-d H:i:s");
     $this->lblNumSolicitante->Text = $VarSolicitante;
     $this->lblSolicitante->Text = $VarSolicitud . " - " . $Solicitud;
     $this->lblFechadeIngreso->Text = $VarFechadeIngreso;
     $this->lblAntiguedad->Text = $AntLetra;
     $this->lblTipoNomina->Text = $TipoNomina;
     $this->lblSindicato->Text = $VarSindicato;
     $this->lblAval1->Text = $Aval1 . " - " . $VarAval1;
     $this->lblAval2->Text = $Aval2 . " - " . $VarAval2;
     $this->lblfirmAvales->Text = $nuevafecha;
     $this->lblmeses->Text = $meses;
     $this->lblimporte->Text = $VarImporte;
     $this->lbldirector->Text = $VarDirector;
 }
Esempio n. 19
0
 function getCalender($week_start = 0)
 {
     $c_str = "";
     $day = 1;
     // カレンダーの情報を設定する
     if ($this->cal == CAL_GREGORIAN) {
         $time = mktime(0, 0, 0, $this->month, $day, $this->year);
         $date = date('Y/m/d', $time);
         $week = date('w', $time);
         $month_end = date('t', $time);
     } else {
         if ($this->cal == CAL_JULIAN) {
             $time = cal_to_jd(CAL_GREGORIAN, $this->month, $this->day, $this->year);
             $date = cal_from_jd($time, CAL_GREGORIAN);
             $date = $date['year'] . '/' . sprintf('%02d', $date['month']) . '/' . sprintf('%02d', $date['day']);
             $week = jddayofweek(cal_to_jd(CAL_GREGORIAN, $this->month, $day, $this->year), 0);
             $month_end = cal_days_in_month(CAL_GREGORIAN, $this->month, $this->year);
         } else {
             return NULL;
         }
     }
     // カレンダーを作成
     $c_str .= '<table class="calenar_table" cellpadding="0" cellspacing="1" summary="カレンダー">' . "\n";
     $c_str .= '<thead><tr>' . "\n";
     foreach ($this->week_str as $key => $val) {
         $c_str .= '<th class="' . $val['week'] . '" abbr="' . $val['abbr'] . '">' . $val['date'] . '</th>' . "\n";
     }
     // 曜日を作成
     $c_str .= '</tr></thead>' . "\n";
     // 日付を設定
     $c_str .= '<tbody>' . "\n";
     $c_str .= '<tr>' . "\n";
     if ($week > 0) {
         $c_str .= '<td class="' . $this->week_str[$week]['week'] . '" colspan="' . $week . '">&nbsp;</td>' . "\n";
     }
     for ($day = 1; $day <= $month_end; $day++, $week++) {
         if ($week >= 7) {
             $week = $week % 7;
             $c_str .= '</tr>' . "\n" . '<tr>' . "\n";
         }
         $text = $day;
         if (isset($this->days[$day])) {
             $text = $this->_replaseDay($this->year, $this->month, $day, $this->days[$day]);
         }
         $class = $this->week_str[$week]['week'];
         if ($this->day == $day) {
             $class .= " today";
         }
         $colspan = '';
         if ($day == $month_end) {
             $colspan = ' colspan="' . (7 - $week) . '"';
         }
         $c_str .= '<td class="' . $class . '"' . $colspan . '>' . $text . '</td>' . "\n";
     }
     $c_str .= '</tr>' . "\n";
     $c_str .= '</tbody>' . "\n";
     // リンクを設定
     $c_str .= '<tfoot>' . "\n";
     $c_str .= '<td class="foot_left" colspan="1">' . $prev . '</td>' . "\n";
     $c_str .= '<td class="foot_center" colspan="5">' . $date . '</td>' . "\n";
     $c_str .= '<td class="foot_left" colspan="1">' . $next . '</td>' . "\n";
     $c_str .= '</tfoot>' . "\n";
     $c_str .= '</table>' . "\n";
     return $c_str;
 }
Esempio n. 20
0
function getDiaFecha($fecha)
{
    $i = strtotime($fecha);
    $dia = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m", $i), date("d", $i), date("Y", $i)));
    switch ($dia) {
        case 0:
            return 'domingo';
        case 1:
            return 'lunes';
        case 2:
            return 'martes';
        case 3:
            return 'miercoles';
        case 4:
            return 'jueves';
        case 5:
            return 'viernes';
        case 5:
            return 'sabado';
    }
}
Esempio n. 21
0
 /**
  * Whether the $datetime is
  *
  * @param DateTime $dateTime
  *
  * @throws \Exception
  * @throws \UnexpectedValueException
  * @return boolean
  */
 protected function onDayFrequency(DateTime $dateTime)
 {
     if ($this->frequency == self::FREQUENCY_DAILY || !$this->dayFrequency->count() || !$this->days->count()) {
         return true;
     }
     // This needs $interval integrated as well... yay.
     while ($this->days->next()) {
         $day = $this->days->current();
         while ($this->dayFrequency->next()) {
             switch ($this->frequency) {
                 case self::FREQUENCY_WEEKLY:
                     $compare = jddayofweek(cal_to_jd(CAL_GREGORIAN, $dateTime->format('m'), $dateTime->format('j'), $dateTime->format('Y')));
                     break;
                 case self::FREQUENCY_MONTHLY:
                     throw new \Exception('Not implemented');
                     break;
                 case self::FREQUENCY_YEARLY:
                     $compare = $dateTime->format('z');
                     break;
                 default:
                     throw new \UnexpectedValueException("The provided frequency `{$this->frequency}` is invalid");
             }
             if ($compare === $day) {
                 return true;
             }
         }
     }
     return false;
 }
 function filtrar()
 {
     //Inicia uma Sessão
     $this->init_session();
     $mes = $this->escape("mes");
     $ano = $this->escape("ano");
     $dias_do_mes = cal_days_in_month(CAL_GREGORIAN, $mes, $ano);
     $semana = 1;
     $auxSemanas["DATAINICIAL"] = "1";
     $auxSemanas["SEMANA"] = "1";
     $auxSemanas["DATAFINAL"] = "";
     $retornoSemana = false;
     for ($d = 1; $d <= $dias_do_mes; $d++) {
         $row["DIA"] = "";
         $row["DIASEMANA"] = "";
         $row["SEMANA"] = "";
         $row["MES"] = $mes;
         $row["ANO"] = $ano;
         $row["DESPESAS"] = 0;
         $row["RECEITAS"] = 0;
         $row["SALDO"] = 0;
         $row["SALDOANTERIOR"] = 0;
         $retornoSemana = false;
         $dia_da_semana = jddayofweek(cal_to_jd(CAL_GREGORIAN, $mes, $d, $ano), 0);
         switch ($dia_da_semana) {
             case 0:
                 $row["DIASEMANA"] = "Domingo";
                 $auxSemanas["DATAFINAL"] = "" . "" . $d . "/" . $mes . "/" . $ano;
                 $semanas[] = $auxSemanas;
                 $semanas2[] = $auxSemanas;
                 $auxSemanas["DATAINICIAL"] = "";
                 $auxSemanas["DATAFINAL"] = "";
                 $retornoSemana = true;
                 break;
             case 1:
                 $row["DIASEMANA"] = "Segunda";
                 if ($d != 1) {
                     $semana++;
                     $auxSemanas["SEMANA"] = "" . $semana;
                 }
                 $auxSemanas["DATAINICIAL"] = "" . $d;
                 break;
             case 2:
                 $row["DIASEMANA"] = "Terca";
                 break;
             case 3:
                 $row["DIASEMANA"] = "Quarta";
                 break;
             case 4:
                 $row["DIASEMANA"] = "Quinta";
                 break;
             case 5:
                 $row["DIASEMANA"] = "Sexta";
                 break;
             case 6:
                 $row["DIASEMANA"] = "Sabado";
                 break;
         }
         if ($retornoSemana == false && $d == $dias_do_mes) {
             $auxSemanas["DATAFINAL"] = "" . "" . $d . "/" . $mes . "/" . $ano;
             $semanas[] = $auxSemanas;
             $semanas2[] = $auxSemanas;
         }
         $row["DIA"] = $d;
         $row["SEMANA"] = $semana;
         $retorno[] = $row;
     }
     $lancamentos = Doctrine_Query::create()->select("l.pagarReceber, " . "l.dataBaixa, " . "sum(valorBaixado) as valorBaixado")->from("Lancamentofinanceiro l")->where("l.status like 'Baixado' and l.origemNotaFiscal = 0 and l.dataBaixa >= '" . $ano . "-" . $mes . "-01' and l.dataBaixa <= '" . $ano . "-" . $mes . "-" . $dias_do_mes . "'")->groupBy("l.pagarReceber, " . "l.dataBaixa")->execute()->toArray();
     $saldoInicial = 0;
     $saldoFinal = 0;
     $totalReceitas = 0;
     $totalDespesas = 0;
     //Recupera todos os registros
     for ($j = 0; $j < count($lancamentos); $j++) {
         $pieces = explode("-", $lancamentos[$j]["dataBaixa"]);
         for ($i = 0; $i < count($retorno); $i++) {
             if ($retorno[$i]["DIA"] == $pieces[2]) {
                 if ($lancamentos[$j]["pagarReceber"] == 0) {
                     $retorno[$i]["DESPESAS"] += $lancamentos[$j]["valorBaixado"];
                     $totalDespesas += $lancamentos[$j]["valorBaixado"];
                 } else {
                     if ($lancamentos[$j]["pagarReceber"] == 1) {
                         $retorno[$i]["RECEITAS"] += $lancamentos[$j]["valorBaixado"];
                         $totalReceitas += $lancamentos[$j]["valorBaixado"];
                     }
                 }
             }
         }
     }
     $saldoAtual = 0;
     for ($i = 0; $i < count($retorno); $i++) {
         $retorno[$i]["SALDOANTERIOR"] = $saldoAtual;
         $retorno[$i]["SALDO"] = $retorno[$i]["SALDOANTERIOR"];
         $retorno[$i]["SALDO"] += $retorno[$i]["RECEITAS"];
         $retorno[$i]["SALDO"] -= $retorno[$i]["DESPESAS"];
         $saldoAtual += $retorno[$i]["RECEITAS"];
         $saldoAtual -= $retorno[$i]["DESPESAS"];
         //$retorno[$i]["SALDOANTERIOR"] = money_format('%.2n', $retorno[$i]["SALDOANTERIOR"]);
         //$retorno[$i]["SALDO"] = money_format('%.2n', $retorno[$i]["SALDO"]);
         //$retorno[$i]["RECEITAS"] = money_format('%.2n', $retorno[$i]["RECEITAS"]);
         //$retorno[$i]["DESPESAS"] = money_format('%.2n', $retorno[$i]["DESPESAS"]);
         $retorno[$i]["SALDOANTERIOR"] = 'R$' . number_format($retorno[$i]["SALDOANTERIOR"], 2, ',', '.');
         $retorno[$i]["SALDO"] = 'R$' . number_format($retorno[$i]["SALDO"], 2, ',', '.');
         $retorno[$i]["RECEITAS"] = 'R$' . number_format($retorno[$i]["RECEITAS"], 2, ',', '.');
         $retorno[$i]["DESPESAS"] = 'R$' . number_format($retorno[$i]["DESPESAS"], 2, ',', '.');
     }
     $saldoFinal = $saldoInicial + $totalReceitas - $totalDespesas;
     //$saldoInicial = money_format('%.2n', $saldoInicial);
     //$saldoFinal = money_format('%.2n', $saldoFinal);
     //$totalReceitas = money_format('%.2n', $totalReceitas);
     //$totalDespesas = money_format('%.2n', $totalDespesas);
     $saldoInicial = 'R$' . number_format($saldoInicial, 2, ',', '.');
     $saldoFinal = 'R$' . number_format($saldoFinal, 2, ',', '.');
     $totalReceitas = 'R$' . number_format($totalReceitas, 2, ',', '.');
     $totalDespesas = 'R$' . number_format($totalDespesas, 2, ',', '.');
     $formaPagamentoDespesas = Doctrine_Query::create()->select("DISTINCT f.*")->from("Formapagamento f")->leftJoin("f.Lancamentofinanceiro l")->where("f.status like 'Ativo' and l.status like 'Baixado' and l.origemNotaFiscal = 0 and l.pagarReceber = 0 and l.dataBaixa >= '" . $ano . "-" . $mes . "-01' and l.dataBaixa <= '" . $ano . "-" . $mes . "-" . $dias_do_mes . "'")->orderBy("f.nome")->execute()->toArray();
     $formaPagamentoReceitas = Doctrine_Query::create()->select("DISTINCT f.*")->from("Formapagamento f")->leftJoin("f.Lancamentofinanceiro l")->where("f.status like 'Ativo' and l.status like 'Baixado' and l.origemNotaFiscal = 0 and l.pagarReceber = 1 and l.dataBaixa >= '" . $ano . "-" . $mes . "-01' and l.dataBaixa <= '" . $ano . "-" . $mes . "-" . $dias_do_mes . "'")->orderBy("f.nome")->execute()->toArray();
     //Envia os Centros de Custo para a página
     $this->set("semanas", $semanas);
     $this->set("semanas2", $semanas2);
     $this->set("calendario", $retorno);
     $this->set("totalReceitas", $totalReceitas);
     $this->set("totalDespesas", $totalDespesas);
     $this->set("saldoInicial", $saldoInicial);
     $this->set("saldoFinal", $saldoFinal);
     $this->set("formaPagamentoDespesas", $formaPagamentoDespesas);
     $this->set("formaPagamentoReceitas", $formaPagamentoReceitas);
     //Abre a página
     $this->show("pages/interno/modulo/financeiro/relatorios/fluxoCaixaSede.tpl");
 }
Esempio n. 23
0
<?php

echo cal_to_jd(CAL_GREGORIAN, 8, 26, 74), "\n";
echo cal_to_jd(CAL_JULIAN, 8, 26, 74), "\n";
echo cal_to_jd(CAL_JEWISH, 8, 26, 74), "\n";
echo cal_to_jd(CAL_FRENCH, 8, 26, 74), "\n";
Esempio n. 24
0
    case 6:
        if ($excludeWeekends) {
            $dayStartWeekendExclusion = 3;
        } else {
            $dayStartWeekendExclusion = 1;
        }
        break;
    default:
        $dayStartWeekendExclusion = 1;
        break;
}
//-- Start the Daily Listings
$_mxcDayItems = '';
for ($counter = $dayStartWeekendExclusion; $counter <= $numdaysinmonth; $counter++) {
    //-- Check to see if we exlcude weekends
    $thisDayofWeek = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m"), date($counter), date("Y")), 0);
    if ($thisDayofWeek != 0 && $thisDayofWeek != 6 && $excludeWeekends || !$excludeWeekends) {
        $rowcounter++;
        if ($counter == (int) date("j") && $evMonth == (int) date("m") && $this->config['mxcCalendarActiveDayDisplay']) {
            $classToday = $this->config['mxcCalendarActiveDayClass'];
        } elseif ($counter == (int) date("j") && $this->config['mxcCalendarActiveDayDisplay']) {
            $classToday = $this->config['mxcCalendarActiveDayClass'];
        } else {
            $classToday = NULL;
        }
        //-- Check if config/param for listing 'todays' events only
        $_todayOnlyCheck = isset($param['mxcMonthListTodayOnly']) && $param['mxcMonthListTodayOnly'] ? $counter == (int) date("j") ? true : false : true;
        //-- List events on this date
        $events = '';
        if (is_array($thisDayEvents) && $_todayOnlyCheck) {
            if (is_array($thisDayEvents[$counter])) {
 function fecha($fecha)
 {
     if ($fecha) {
         $p = split(" ", $fecha);
         $f = split("-", $p[0]);
         $h = split(":", $p[1]);
         /*** nombre dia semana ***/
         //$fecha= "2010/02/15";
         $i = strtotime($fecha);
         $numDiaSem = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m", $i), date("d", $i), date("Y", $i)), 0);
         //$diasemana = date("w", $fecha);
         $diasemanales = array("Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sáb");
         $diasemana = $diasemanales[$numDiaSem];
         //cambio de fecha
         $nummes = (int) $f[1];
         $mes1 = "0-Ene-Feb-Mar-Abr-May-Jun-Jul-Ago-Sep-Oct-Nov-Dic";
         $mes1 = split("-", $mes1);
         //cambio de hora
         $numhora = (int) $h[0];
         $momento = 'a.m.';
         if ($numhora >= 13) {
             $numhora = $numhora - 12;
             $momento = 'p.m.';
         }
         $desfechahora = "{$diasemana}, {$f['2']} {$mes1[$nummes]} {$f['0']} {$numhora}:{$h['1']} {$momento}";
         return $desfechahora;
     }
 }
Esempio n. 26
0
			        $tiempo_alquiler=$miconexion->consulta_lista();
			        $Hora = strtotime($_POST['hora_partido']) + (60 *60 * $tiempo_alquiler[0]);
			        $hora_fin = "".date('H:i:s',$Hora);
			        $centro = $_POST['id_centro'];
			        $fecha_partido = $_POST['fecha_partido'];
			        $hora_partido = $_POST['hora_partido'];
			        $sql = 'select count(*) from partidos where id_centro="'.$centro.'" and estado_partido = 1 and id_partido != "'.$_POST['id_partido'].'" and FECHA_PARTIDO = "'.$fecha_partido.'" and 
		        ((("'.$hora_partido.'" >= hora_partido and  "'.$hora_partido.'" < hora_fin) and ("'.$hora_fin.'"  > hora_partido and "'.$hora_fin.'"  >= hora_fin)) 
		        or (("'.$hora_partido.'" <= hora_partido and  "'.$hora_partido.'" > hora_fin) and ("'.$hora_fin.'" > hora_partido and "'.$hora_fin.'"  <= hora_fin)) 
		        or (hora_partido > "'.$hora_partido.'" AND hora_partido < "'.$hora_fin.'" ))';
			        if($miconexion->consulta($sql)){
			        	$compr=$miconexion->consulta_lista();
			            if ($compr[0]=="0") {
			                $dias= array("0"=>'Domingo',"1"=>'Lunes',"2"=>'Martes',"3"=>'Miercoles',"4"=>'Jueves',"5"=>'Viernes',"6"=>'Sabado');
			                $i = strtotime($_POST['fecha_partido']); 
			                $dia_fecha = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m",$i),date("d",$i), date("Y",$i)) , 0 );
			                $miconexion->consulta('select count(*) from horarios_centros where  id_centro="'.$centro.'" and dia="'.$dias[$dia_fecha].'" and 
			                                    ("'.$hora_partido.'" >= hora_inicio AND "'.$hora_partido.'" < hora_fin)
			                                     AND 
			                                    ("'.$hora_fin.'" >= hora_inicio AND "'.$hora_fin.'" < hora_fin)');    
			                $compr=$miconexion->consulta_lista();
			                if ($compr[0]!="0") {
			                $columnas[count($columnas)] = "hora_fin";
			                $lista[count($lista)] = $hora_fin;
							$sql=$miconexion->sql_actualizar($bd,$lista,$columnas);
							    if($miconexion->consulta($sql)){
							    	$sql = "insert into notificaciones (id_user, id_partido, fecha_not, visto, responsable, tipo, mensaje) 
                                            values ('".$tiempo_alquiler[1]."','".$_POST['id_partido']."','".date('Y-m-d H:i:s', time())."','0','".$_SESSION['id']."','cambios',' ha solicitado reservar el ".$_POST['fecha_partido']." a las ".date('g:i a', strtotime($_POST['hora_partido']))." para el partido')";
                                    $miconexion->consulta($sql);
							        echo '<script>
							        	$.get("../datos/cargarNotificaciones.php");
Esempio n. 27
0
function llistaCalendariV($DATAI, $CALENDARI)
{
    //Inicialitzem variables i marquem els dies en blanc
    $Q = 3;
    $mes = date('m', $DATAI);
    $year = date('Y', $DATAI);
    $RET = "";
    $any = $year;
    $mesI = $mes;
    $mesF = $mes + $Q;
    //Omplim els mesos
    $RET .= '<tr>';
    $dies = array();
    $IndexMes = 0;
    for ($mes = $mesI; $mes < $mesF; $mes++) {
        $mesReal = $mes > 12 ? $mes - 12 : $mes;
        $anyReal = $mes == 13 ? $any + 1 : $any;
        $week = 1;
        $IndexMes++;
        $diesMes = cal_days_in_month(CAL_GREGORIAN, $mesReal, $anyReal);
        for ($dia = 1; $dia <= $diesMes; $dia++) {
            $diaSetmana = jddayofweek(cal_to_jd(CAL_GREGORIAN, $mesReal, $dia, $anyReal), 0);
            $diaSetmana = $diaSetmana == 0 ? 7 : $diaSetmana;
            $dies[$week][$diaSetmana][$IndexMes]['day'] = $dia;
            $dies[$week][$diaSetmana][$IndexMes]['month'] = $mesReal;
            $dies[$week][$diaSetmana][$IndexMes]['year'] = $anyReal;
            if ($diaSetmana == 7) {
                $week++;
            }
        }
        $RET .= "<TD class=\"titol_mes\" colspan=\"7\">" . mesos($mesReal) . "</TD><td width=\"20px\"></td>";
    }
    $RET .= '</tr>';
    $RET .= "<TR>";
    for ($i = 0; $i < $Q; $i++) {
        $RET .= "<TD>Dll</TD><TD>Dm</TD><TD>Dc</TD><TD>Dj</TD><TD>Dv</TD><TD>Ds</TD><TD>Dg</TD><TD></TD>";
    }
    $RET .= "</TR>";
    for ($row = 1; $row <= 6; $row++) {
        $RET .= "<tr>";
        for ($col = 1; $col <= 7 * $Q; $col++) {
            $IndexMes = ceil($col / 7);
            $colR = $col - 7 * ($IndexMes - 1);
            //Color de fons per diferenciar els mesos
            if ($IndexMes % 2) {
                $background = "beige";
            } else {
                $background = "beige";
            }
            //Color de fons per diferenciar els caps de setmana
            if ($colR == 6 || $colR == 7) {
                $background = "#CCCCCC";
            }
            if (isset($dies[$row][$colR][$IndexMes])) {
                $dades = $dies[$row][$colR][$IndexMes];
                $SPAN = "";
                $color = "";
                $CalDia = mktime(0, 0, 0, $dades['month'], $dades['day'], $dades['year']);
                if (isset($CALENDARI[$CalDia])) {
                    $SELECCIONAT = "SELECCIONAT";
                    $SPAN = '<span><table id="TD1"><tr><th>Inici</th><th>Fi</th><th>Espai</th><th>Títol</th><th>Organitzador</th></tr>';
                    foreach ($CALENDARI[$CalDia] as $CAL) {
                        $SPAN .= '<tr><td>' . $CAL['HORAI'] . '</td><td>' . $CAL['HORAF'] . '</td><td>' . $CAL['ESPAIS'] . '</td><td>' . $CAL['TITOL'] . '</td><td>' . $CAL['ORGANITZADOR'] . '</td></tr>';
                    }
                    $SPAN .= '</table></span>';
                } else {
                    $SELECCIONAT = "";
                }
                $RET .= '<TD class="DIES" style="background-color:' . $background . ';">' . link_to($dades['day'] . $SPAN, "gestio/gActivitats?accio=CD&DIA=" . $CalDia, array('class' => "tt2 {$SELECCIONAT}")) . '</TD>';
            } else {
                $RET .= '<TD class="DIES" style="background-color:' . $background . ';"></TD>';
            }
            if ($colR == 7) {
                $RET .= '<td></td>';
            }
        }
        $RET .= "</tr>";
    }
    $RET .= "</TR>";
    return $RET;
}
Esempio n. 28
0
$TotcolumnO = 0;
//P
$TotcolumnP = 0;
//Q
$TotcolumnQ = 0;
//R
//	$TotcolumnR=0;
//S
$TotcolumnS = 0;
//T
$TotcolumnT = 0;
$trClass = "tr1";
while ($intRowNumber < $arrLength) {
    $goLiveDate = cal_to_jd(CAL_GREGORIAN, substr($arrMembersGoLiveDate[$intRowNumber], 5, 2), substr($arrMembersGoLiveDate[$intRowNumber], 8, 2), substr($arrMembersGoLiveDate[$intRowNumber], 0, 4));
    $dateExplode = explode('/', $_GET['pdateFrom']);
    $fromdate = cal_to_jd(CAL_GREGORIAN, $dateExplode[0], $dateExplode[1], $dateExplode[2]);
    $daysDiff = $goLiveDate - $fromdate;
    if ($_GET['pchkUse365'] == 1) {
        if ($goLiveDate > $fromdate) {
            $NoofDaysYTD = 365 - $daysDiff;
        } else {
            $NoofDaysYTD = 365;
        }
    } else {
        if ($goLiveDate > $firstOfCurrentYear) {
            $NoofDaysYTD = date("z") - ($goLiveDate - $firstOfCurrentYear);
        } else {
            $NoofDaysYTD = date("z") + 1;
        }
    }
    echo "<tr class=\"" . $trClass . "\">";
Esempio n. 29
0
function deliveryDate()
{
    //lay ngay hien tai bang so
    $str = @date("d-m-Y-g:i a");
    $currentDay = date_to_int($str);
    //@strtotime(date("d-m-Y-g:i a"));
    $totalDay = 1 * 24 * 60 * 60;
    //1 ngay: 1*24*60*60
    $h = @date("g");
    //lay gio
    $m = @date("a");
    // lay buoi sang hay buoi chieu
    // am la buoi chieu tu 1->12 toi
    //pm la tu 1->12 chua
    if ($m == 'pm') {
        //nay du kien giao hang la---------------
        $tongngay = $currentDay + $totalDay;
        $toado = explode("-", int_to_dateNoH($tongngay));
        $jd = cal_to_jd(CAL_GREGORIAN, $toado[1], $toado[0], $toado[2]);
        $day = jddayofweek($jd, 0);
        switch ($day) {
            case 0:
                $thu = DSUNDAY;
                break;
            case 1:
                $thu = DMONDAY;
                break;
            case 2:
                $thu = DTUEDAY;
                break;
            case 3:
                $thu = DWDNESDAY;
                break;
            case 4:
                $thu = DTHUDAY;
                break;
            case 5:
                $thu = DFRIDAY;
                break;
            case 6:
                $thu = DSATUDAY;
                break;
        }
        $ngaygiaohang = $thu . ', ' . int_to_dateNoH($tongngay) . ': 3 ' . _dH . ' 30 ' . DMINUTES;
    } elseif ($m == 'am' and $h < 7) {
        $toado = explode("-", int_to_dateNoH($currentDay));
        $jd = cal_to_jd(CAL_GREGORIAN, $toado[1], $toado[0], $toado[2]);
        $day = jddayofweek($jd, 0);
        switch ($day) {
            case 0:
                $thu = DSUNDAY;
                break;
            case 1:
                $thu = DMONDAY;
                break;
            case 2:
                $thu = DTUEDAY;
                break;
            case 3:
                $thu = DWDNESDAY;
                break;
            case 4:
                $thu = DTHUDAY;
                break;
            case 5:
                $thu = DFRIDAY;
                break;
            case 6:
                $thu = DSATUDAY;
                break;
        }
        $ngaygiaohang = $thu . ', ' . int_to_dateNoH($currentDay) . ': 3 ' . _dH . ' 30 ' . DMINUTES;
    } else {
        $toado = explode("-", int_to_dateNoH($tongngay));
        $jd = cal_to_jd(CAL_GREGORIAN, $toado[1], $toado[0], $toado[2]);
        $day = jddayofweek($jd, 0);
        switch ($day) {
            case 0:
                $thu = DSUNDAY;
                break;
            case 1:
                $thu = DMONDAY;
                break;
            case 2:
                $thu = DTUEDAY;
                break;
            case 3:
                $thu = DWDNESDAY;
                break;
            case 4:
                $thu = DTHUDAY;
                break;
            case 5:
                $thu = DFRIDAY;
                break;
            case 6:
                $thu = DSATUDAY;
                break;
        }
        $ngaygiaohang = $thu . ', ' . int_to_date($tongngay) . ': 8 ' . _dH . ' 30 ' . DMINUTES;
    }
    $currentDay = date_to_int($str);
    return $ngaygiaohang;
}
Esempio n. 30
-1
 function vehicle_print($data)
 {
     require_once "assets/escpos-php/Escpos.php";
     try {
         // Enter the share name for your USB printer here
         $connector = new WindowsPrintConnector("epson");
         $printer = new Escpos($connector);
         $age = array("Monday" => "35", "Tuesday" => "37", "Wednesday" => "43");
         $day = jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m"), date("d"), date("Y")), 1);
         /* Print top logo */
         /*print report start*/
         $exceldata = "";
         $t_charges = 0;
         $total_hours = 0;
         foreach ($data->result_array() as $row) {
             $pid = $row['pid'];
             $vtype = $row['name'];
             $noplate = $row['noplate'];
             $intime = $row['intime'];
             if ($row['status'] == 0) {
                 $status = 'IN';
             }
             if ($row['status'] == 1) {
                 $status = 'OUT';
             }
             if (isset($row['outtime'])) {
                 $outtime = $row['outtime'];
                 $new_hours = $row['hours'];
                 $total_charges = $row['charges'];
             } else {
                 $in = $row['intime'];
                 $out = date('Y-m-d H:i:s', time());
                 $hour1 = 0;
                 $hour2 = 0;
                 $date1 = $in;
                 $date2 = $out;
                 $datetimeObj1 = new DateTime($date1);
                 $datetimeObj2 = new DateTime($date2);
                 $interval = $datetimeObj1->diff($datetimeObj2);
                 if ($interval->format('%a') > 0) {
                     $hour1 = $interval->format('%a') * 24;
                 }
                 if ($interval->format('%h') > 0) {
                     $hour2 = $interval->format('%h');
                 }
                 $hrs = $hour1 + $hour2;
                 $hrs = sprintf("%02d", $hrs);
                 $minutes = $interval->format('%i');
                 $minutes = sprintf("%02d", $minutes);
                 $secs = $interval->format('%s');
                 $secs = sprintf("%02d", $secs);
                 $new_hours = $hrs . ":" . $minutes . ":" . $secs;
                 $sql = "select charges from charges where typeid = (select id from parktype where name = '{$vtype}' )";
                 $query = $this->db->query($sql);
                 $result = $query->result();
                 $result1 = array();
                 foreach ($result as $key => $value) {
                     $result1['charges'] = $value->charges;
                 }
                 $charges = $result1['charges'];
                 $tot_str = $hrs . '.' . $minutes;
                 $hour_in_float = (double) $tot_str;
                 $total_charges = ceil($hour_in_float / 8) * $charges;
             }
             $to_seconds = $this->time_to_seconds($new_hours);
             /*******total hours calculation*****/
             $total_hours = $total_hours + $to_seconds;
             $hours = floor($total_hours / (60 * 60));
             $divisor_for_minutes = $total_hours % (60 * 60);
             $minutes = floor($divisor_for_minutes / 60);
             // extract the remaining seconds
             $divisor_for_seconds = $divisor_for_minutes % 60;
             $seconds = ceil($divisor_for_seconds);
             $t_hours_sec = (int) $hours . ':' . (int) $minutes . ':' . (int) $seconds;
             /***********average hours calculation*********/
             $ave_hours = $total_hours / count($data->result_array());
             $hours = floor($ave_hours / (60 * 60));
             $divisor_for_minutes = $ave_hours % (60 * 60);
             $minutes = floor($divisor_for_minutes / 60);
             $divisor_for_seconds = $divisor_for_minutes % 60;
             $seconds = ceil($divisor_for_seconds);
             $ave_sec = (int) $hours . ':' . (int) $minutes . ':' . (int) $seconds;
             /*****************/
             $exceldata[] = array($pid, $vtype, $noplate, $intime, $row['outtime'], $new_hours, $total_charges, $status);
             $charges = $total_charges;
             $charges_t = $charges_t + $charges;
             $ii = 1;
             $objPHPExcel->getActiveSheet()->getStyle('A' . $ii . ':H' . $ii)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
             $ii++;
         }
         $exceldata[] = array('', 'TOTAl :' . count($data->result_array()), 'Total Hours :', $t_hours_sec, 'average hours :', $ave_sec, 'Total Charges  :', $charges_t);
         //$exceldata[] = array('','','','','','average hours :'.$ave_sec,'','');
         $excel_c = count($data->result_array()) + 4;
         /*for($col = ord('A'.$excel_c); $col <= ord('F'.$excel_c); $col++){
              $objPHPExcel->getActiveSheet()->getStyle(chr($col))->getFont()->setSize(14);
               $objPHPExcel->getActiveSheet()->getStyle(chr($col))->getFont()->setBold(true);
               $objPHPExcel->getActiveSheet()->getStyle(chr($col))->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
           }*/
         //$objPHPExcel->getActiveSheet()->getColumnDimension('G'.$excel_c)->setWidth(20);
         $objPHPExcel->getActiveSheet()->getRowDimension($excel_c)->setRowHeight(20);
         $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
         $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getFill()->getStartColor()->setARGB('29bb04');
         $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getFont()->setSize(14);
         $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getFont()->setBold(true);
         $objPHPExcel->getActiveSheet()->getStyle('A' . $excel_c . ':H' . $excel_c)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
         //Fill data
         $objPHPExcel->getActiveSheet()->fromArray($exceldata, null, 'A4');
         /*print report end*/
         $printer->setJustification(Escpos::JUSTIFY_CENTER);
         /* Name of shop */
         $printer->selectPrintMode(Escpos::MODE_DOUBLE_WIDTH);
         $printer->text("RECEIPT\n");
         $printer->text("\nNhavaSheva toll plaza\n");
         $printer->text("Operated By\n");
         $printer->text("Shree Sai Samartha\n");
         $printer->text("Enterprises Pay & Park\n");
         $printer->selectPrintMode();
         $printer->feed();
         /* Title of receipt */
         /* Items */
         $printer->setJustification(Escpos::JUSTIFY_LEFT);
         $printer->setEmphasis(true);
         $printer->setTextSize(2, 1);
         $rr = "RECEIPT NO :" . $receipt . "\n";
         $printer->text($rr);
         //$printer -> feed();
         $printer->text("V. TYPE    :" . $parktype . "\n");
         $printer->feed();
         $printer->setTextSize(2, 2);
         $printer->text("V.NO       :" . $noplate . "\n");
         $printer->text("CO. NO     :" . $containerno . "\n");
         $printer->text("VO. NO     :" . $invoiceno . "\n");
         //$printer -> feed();
         //$printer -> setTextSize(2,1);
         $printer->text("IN  DT :" . date('d/m/Y', strtotime($intime)) . "\n");
         $printer->text("IN  TM :" . date('h:i:s', strtotime($intime)) . "\n");
         $printer->setTextSize(2, 2);
         $printer->setTextSize(1, 1);
         $printer->setEmphasis(false);
         $printer->feed();
         /* Tax and total */
         /* Footer */
         //$printer -> feed(1);
         $printer->setJustification(Escpos::JUSTIFY_CENTER);
         $printer->text("PARKING AT OWNERS RISK. MANAGEMENT IS NOT LIABLE\n");
         $printer->text("TO PAY ANY LOSS OR DAMAGE OF ANY VEHICLE OR\n");
         $printer->text("VALUABLE LEFT INSIDE IT\n");
         //$printer -> feed(1);
         //$printer -> text(date('l jS \of F Y h:i:s A') . "\n");
         /* Cut the receipt and open the cash drawer */
         $printer->cut();
         $printer->pulse();
         $printer->close();
     } catch (Exception $e) {
         echo "Couldn't print to this printer: " . $e->getMessage() . "\n";
     }
     /* A wrapper to do organise item names & prices into columns */
     /* Close printer */
 }