Example #1
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;
 }
Example #2
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));
 }
Example #4
0
 function calculateDOW($input)
 {
     $int_date = $this->formatDate($input);
     if ($int_date) {
         return jddayofweek($int_date, 1);
     } else {
         return "Invalid Date";
     }
 }
 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;
 }
 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));
 }
Example #7
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;
 }
    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');
 }
Example #12
0
 /**
  * render calendar called in view via helper
  * @param mixed $date
  * @param Array $options
  */
 public function render($date = null, $options = array())
 {
     $calendar = $this->parsed($date);
     $this->buildConfig($options);
     $container = new DomBuilder('div', array('id' => $this->style['div']));
     for ($month = 0; $month < $this->displayedMonth; $month++) {
         $monthDays = cal_days_in_month(CAL_GREGORIAN, $calendar->format('n'), $calendar->format('Y'));
         if ($calendar->format('j') != 1) {
             $calendar->sub(new \DateInterval("P{$calendar->format('j')}D"))->add(new \DateInterval("P1D"));
         }
         $firstDay = $calendar->format('N');
         $weeks = ceil(($monthDays + $firstDay) / 7);
         $table = new DomBuilder('table', array('class' => $this->style['table']));
         $th = $table->addChild('thead')->addChild('tr', array('class' => $this->style['title']))->addChild('th', array('colspan' => 7, 'class' => $this->style['title']));
         $th->content = $calendar->format('F Y');
         $days = $table->get('thead')->addChild('tr');
         for ($day = 0; $day < 7; $day++) {
             $cell = $days->addChild('th');
             $cell->content = $this->abbreviate ? jddayofweek($day, 2) : jddayofweek($day, 1);
         }
         for ($week = 0; $week < $weeks; $week++) {
             $weekdate = $table->addChild('tr');
             for ($day = 0; $day < 7; $day++) {
                 $cellNumber = $week * 7 + $day;
                 $class = $calendar->format('d-m-Y') == date('d-m-Y') ? $this->style['current'] : null;
                 $cell = $weekdate->addChild('td', array('class' => $class));
                 if ($cellNumber + 1 >= $firstDay && $cellNumber + 1 < $monthDays + $firstDay) {
                     $cell->content = $this->renderCell($calendar);
                     $calendar->add(new \DateInterval("P1D"));
                 }
             }
         }
         $container->addChild($table);
     }
     return $container->render();
 }
Example #13
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';
?>
 
Example #14
0
 /**
  * Given a string representation of a set of weekdays, returns an array of
  * possible dates.
  */
 function getWeekDays($str, $month, $year)
 {
     $daysInMonth = $this->daysinmonth($month, $year);
     if (strstr($str, ",")) {
         $tmp1 = explode(",", $str);
         $count = count($tmp1);
         for ($i = 0; $i < $count; $i++) {
             //Loop through each comma-separated value
             if (strstr($tmp1[$i], "-")) {
                 //If there's a range in this place, expand that too
                 $tmp2 = explode("-", $tmp1[$i]);
                 for ($j = $start; $j <= $tmp2[1]; $j++) {
                     for ($n = 1; $n <= $daysInMonth; $n++) {
                         if ($j == jddayofweek(gregoriantojd($month, $n, $year), 0)) {
                             $ret[] = $n;
                         }
                     }
                 }
             } else {
                 //Otherwise, just add the value
                 for ($n = 1; $n <= $daysInMonth; $n++) {
                     if ($tmp1[$i] == jddayofweek(gregoriantojd($month, $n, $year), 0)) {
                         $ret[] = $n;
                     }
                 }
             }
         }
     } else {
         if (strstr($str, "-")) {
             //There might only be a range, no comma sep values at all.  Just loop these
             $range = explode("-", $str);
             for ($i = $start; $i <= $range[1]; $i++) {
                 for ($n = 1; $n <= $daysInMonth; $n++) {
                     if ($i == jddayofweek(gregoriantojd($month, $n, $year), 0)) {
                         $ret[] = $n;
                     }
                 }
             }
         } else {
             //Otherwise, it's a single value
             for ($n = 1; $n <= $daysInMonth; $n++) {
                 if ($str == jddayofweek(gregoriantojd($month, $n, $year), 0)) {
                     $ret[] = $n;
                 }
             }
         }
     }
     return $ret;
 }
Example #15
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");
Example #16
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;
 }
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';
    }
}
Example #18
0
                                <tr><th colspan="7">Lectures</th></tr>

                                <?php 
        foreach ($section['lect'] as $lecture) {
            echo '<tr><td colspan="3"></td><td>' . $lecture->room . '</td><td>' . my_time($lecture->start) . '</td><td>' . my_time($lecture->end) . '</td><td>' . jddayofweek($lecture->weekday - 1 % 7, 1) . '</td></tr>';
        }
        if ($section['tuts']) {
            echo '<tr><th colspan="7">Tutorials</th></tr>';
            foreach ($section['tuts'] as $tutorial) {
                echo '<tr><td>' . $tutorial->letter . '</td><td>' . $tutorial->instructor . '</td><td>' . $tutorial->capacity . '</td><td>' . $tutorial->room . '</td><td>' . my_time($tutorial->start) . '</td><td>' . my_time($tutorial->end) . '</td><td>' . jddayofweek($tutorial->weekday - 1 % 7, 1) . '</td></tr>';
            }
        }
        if ($section['labs']) {
            echo '<tr><th colspan="7">Laboratories</th></tr>';
            foreach ($section['labs'] as $laboratory) {
                echo '<tr><td>' . $laboratory->letter . '</td><td>' . $laboratory->instructor . '</td><td>' . $laboratory->capacity . '</td><td>' . $laboratory->room . '</td><td>' . my_time($laboratory->start) . '</td><td>' . my_time($laboratory->end) . '</td><td>' . jddayofweek($laboratory->weekday - 1 % 7, 1) . '</td></tr>';
            }
        }
        ?>

                            </tbody>

                        </table>

                    </div>

                <?php 
    }
    ?>

            <?php 
Example #19
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;
 }
Example #20
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;
}
Example #21
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;
}
Example #22
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])) {
Example #23
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;
}
Example #24
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 {
Example #25
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;
 }
Example #26
0
        $tmp = get_jd_dmy($a_jd);
        $a_time = "{$tmp['0']}/{$tmp['1']}/{$tmp['2']}";
        switch ($a_mode) {
            case 1:
                return strftime("%A", strtotime("{$a_time}"));
            case 2:
                return strftime("%a", strtotime("{$a_time}"));
            default:
                return strftime("%w", strtotime("{$a_time}"));
        }
    }
}
$jd = cal_to_jd(CAL_GREGORIAN, date('m', $tme), date('d', $tme), date('y', $tme));
//$jd =unixtojd(time);
$tmp = get_jd_dmy($jd);
$julian = $tmp[0] . '-' . $tmp[1] . '-' . $tmp[2] . ' (' . jddayofweek($jd, 1) . '/' . jdmonthname($jd, 1) . ')';
//$french_date = jdtofrench($jd);
//correct for half-day offset
$dayfrac = date('G') / 24 - 0.5;
if ($dayfrac < 0) {
    $dayfrac += 1;
}
//now set the fraction of a day
$frac = $dayfrac + (date('i') + date('s') / 60) / 60 / 24;
$julianDate = $jd + $frac;
$g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
$j_month_name = array("", "Farvardin", "Ordibehesht", "Khordad", "Tir", "Mordad", "Shahrivar", "Mehr", "Aban", "Azar", "Dey", "Bahman", "Esfand");
function div($a, $b)
{
    return (int) ($a / $b);
 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");
 }
Example #28
0
/**
 *	Fonction retournant le nombre de jour fieries samedis et dimanches entre 2 dates entrees en timestamp
 *	Called by function num_open_day
 *
 *	@param	    timestamp	$timestampStart     Timestamp de debut
 *	@param	    timestamp	$timestampEnd       Timestamp de fin
 *  @param      string		$countrycode        Country code
 *	@return   	int								Nombre de jours feries
 */
function num_public_holiday($timestampStart, $timestampEnd, $countrycode = 'FR')
{
    $nbFerie = 0;
    while ($timestampStart != $timestampEnd) {
        $ferie = false;
        $countryfound = 0;
        $jour = date("d", $timestampStart);
        $mois = date("m", $timestampStart);
        $annee = date("Y", $timestampStart);
        if ($countrycode == 'FR') {
            $countryfound = 1;
            // Definition des dates feriees fixes
            if ($jour == 1 && $mois == 1) {
                $ferie = true;
            }
            // 1er janvier
            if ($jour == 1 && $mois == 5) {
                $ferie = true;
            }
            // 1er mai
            if ($jour == 8 && $mois == 5) {
                $ferie = true;
            }
            // 5 mai
            if ($jour == 14 && $mois == 7) {
                $ferie = true;
            }
            // 14 juillet
            if ($jour == 15 && $mois == 8) {
                $ferie = true;
            }
            // 15 aout
            if ($jour == 1 && $mois == 11) {
                $ferie = true;
            }
            // 1 novembre
            if ($jour == 11 && $mois == 11) {
                $ferie = true;
            }
            // 11 novembre
            if ($jour == 25 && $mois == 12) {
                $ferie = true;
            }
            // 25 decembre
            // Calcul du jour de paques
            $date_paques = easter_date($annee);
            $jour_paques = date("d", $date_paques);
            $mois_paques = date("m", $date_paques);
            if ($jour_paques == $jour && $mois_paques == $mois) {
                $ferie = true;
            }
            // Paques
            // Calcul du jour de l ascension (38 jours apres Paques)
            $date_ascension = mktime(date("H", $date_paques), date("i", $date_paques), date("s", $date_paques), date("m", $date_paques), date("d", $date_paques) + 38, date("Y", $date_paques));
            $jour_ascension = date("d", $date_ascension);
            $mois_ascension = date("m", $date_ascension);
            if ($jour_ascension == $jour && $mois_ascension == $mois) {
                $ferie = true;
            }
            //Ascension
            // Calcul de Pentecote (11 jours apres Paques)
            $date_pentecote = mktime(date("H", $date_ascension), date("i", $date_ascension), date("s", $date_ascension), date("m", $date_ascension), date("d", $date_ascension) + 11, date("Y", $date_ascension));
            $jour_pentecote = date("d", $date_pentecote);
            $mois_pentecote = date("m", $date_pentecote);
            if ($jour_pentecote == $jour && $mois_pentecote == $mois) {
                $ferie = true;
            }
            //Pentecote
            // Calul des samedis et dimanches
            $jour_julien = unixtojd($timestampStart);
            $jour_semaine = jddayofweek($jour_julien, 0);
            if ($jour_semaine == 0 || $jour_semaine == 6) {
                $ferie = true;
            }
            //Samedi (6) et dimanche (0)
        }
        // Pentecoste and Ascensione in Italy go to the sunday after: isn't holiday.
        // Pentecoste is 50 days after Easter, Ascensione 40
        if ($countrycode == 'IT') {
            $countryfound = 1;
            // Definition des dates feriees fixes
            if ($jour == 1 && $mois == 1) {
                $ferie = true;
            }
            // Capodanno
            if ($jour == 6 && $mois == 1) {
                $ferie = true;
            }
            // Epifania
            if ($jour == 25 && $mois == 4) {
                $ferie = true;
            }
            // Anniversario Liberazione
            if ($jour == 1 && $mois == 5) {
                $ferie = true;
            }
            // Festa del Lavoro
            if ($jour == 2 && $mois == 6) {
                $ferie = true;
            }
            // Festa della Repubblica
            if ($jour == 15 && $mois == 8) {
                $ferie = true;
            }
            // Ferragosto
            if ($jour == 1 && $mois == 11) {
                $ferie = true;
            }
            // Tutti i Santi
            if ($jour == 8 && $mois == 12) {
                $ferie = true;
            }
            // Immacolata Concezione
            if ($jour == 25 && $mois == 12) {
                $ferie = true;
            }
            // 25 decembre
            if ($jour == 26 && $mois == 12) {
                $ferie = true;
            }
            // Santo Stefano
            // Calcul du jour de paques
            $date_paques = easter_date($annee);
            $jour_paques = date("d", $date_paques);
            $mois_paques = date("m", $date_paques);
            if ($jour_paques == $jour && $mois_paques == $mois) {
                $ferie = true;
            }
            // Paques
            // Calul des samedis et dimanches
            $jour_julien = unixtojd($timestampStart);
            $jour_semaine = jddayofweek($jour_julien, 0);
            if ($jour_semaine == 0 || $jour_semaine == 6) {
                $ferie = true;
            }
            //Samedi (6) et dimanche (0)
        }
        // Cas pays non defini
        if (!$countryfound) {
            // Calul des samedis et dimanches
            $jour_julien = unixtojd($timestampStart);
            $jour_semaine = jddayofweek($jour_julien, 0);
            if ($jour_semaine == 0 || $jour_semaine == 6) {
                $ferie = true;
            }
            //Samedi (6) et dimanche (0)
        }
        // On incremente compteur
        if ($ferie) {
            $nbFerie++;
        }
        // Incrementation du nombre de jour (on avance dans la boucle)
        $jour++;
        $timestampStart = mktime(0, 0, 0, $mois, $jour, $annee);
    }
    return $nbFerie;
}
Example #29
0
 private function first_day_of_month($date)
 {
     list($aa, $mm, $dd) = explode('-', $date);
     return ($d = jddayofweek(GregorianToJD($mm, 1, $aa), 0)) == 0 ? 7 : $d;
 }
Example #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 */
 }