check
This commit is contained in:
0
lib/Dojo/Model/Data/admin/tienda/json/qStore.q
Normal file → Executable file
0
lib/Dojo/Model/Data/admin/tienda/json/qStore.q
Normal file → Executable file
0
lib/Dojo/Model/Data/admin/tienda/qStore.q
Normal file → Executable file
0
lib/Dojo/Model/Data/admin/tienda/qStore.q
Normal file → Executable file
@@ -1,10 +1,6 @@
|
||||
|
||||
select distinct
|
||||
concat(mes.nombre,' ',year(evento.fecha_inicio)) as text,
|
||||
date_format(evento.fecha_inicio,'%Y%m') as id
|
||||
from evento
|
||||
inner join mes on month(evento.fecha_inicio)=mes.id
|
||||
where evento.estado=1
|
||||
order by evento.fecha_inicio
|
||||
;
|
||||
|
||||
month(tienda_evento.fecha_inicio) as month,
|
||||
year(tienda_evento.fecha_inicio) as year,
|
||||
date_format(tienda_evento.fecha_inicio,'%Y%m') as id
|
||||
from tienda_evento
|
||||
where estado=1 and estore = 1;
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
|
||||
select
|
||||
date_format(evento.fecha_inicio,'%Y%m') as bid,
|
||||
evento.id as eeid,
|
||||
date_format(tienda_evento.fecha_inicio,'%Y%m') as bid,
|
||||
tienda_evento.id as eeid,
|
||||
concat(lugar.municipio,", ",lugar.federativa) as ciudad,
|
||||
concat(lugar.nombre,". ") as lugar,
|
||||
lugar.direccion as dir,
|
||||
case when month(evento.fecha_inicio) = month(evento.fecha_fin)
|
||||
then concat("Del ", day(evento.fecha_inicio)," al ",day(evento.fecha_fin)," de ",mi.nombre)
|
||||
else concat("Del ",day(evento.fecha_inicio)," de ",mi.nombre," al ",
|
||||
day(evento.fecha_fin)," de ", mo.nombre)
|
||||
end as fecha,
|
||||
day(tienda_evento.fecha_inicio) as dini,
|
||||
day(tienda_evento.fecha_fin) as dfin,
|
||||
month(tienda_evento.fecha_inicio) as mini,
|
||||
month(tienda_evento.fecha_fin) as mfin,
|
||||
curso.nombre as nombre,
|
||||
evento.imagen_chica as imagen_chica
|
||||
from evento
|
||||
inner join lugar on evento.lugar_id=lugar.id
|
||||
inner join curso on evento.curso_id=curso.id
|
||||
join mes as mi on mi.id=month(evento.fecha_inicio)
|
||||
join mes as mo on mo.id=month(evento.fecha_fin)
|
||||
where evento.estado=1
|
||||
order by evento.fecha_inicio
|
||||
tienda_evento.imagen_chica as imagen_chica
|
||||
from tienda_evento
|
||||
inner join lugar on tienda_evento.lugar_id=lugar.id
|
||||
inner join curso on tienda_evento.curso_id=curso.id
|
||||
where tienda_evento.estado=1 and tienda_evento.estore=1
|
||||
order by tienda_evento.fecha_inicio
|
||||
;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
select
|
||||
|
||||
curso.nombre as cname,
|
||||
@@ -7,23 +7,20 @@ select
|
||||
lugar.direccion as paddr,
|
||||
lugar.observacion as pobs,
|
||||
lugar.municipio as city,
|
||||
evento.precio as cost,
|
||||
case evento.promo_estado when 1 then coalesce(evento.promocion,"") else "" end as promo,
|
||||
tienda_evento.precio as cost,
|
||||
tienda_evento.spay as spay,
|
||||
case tienda_evento.promo_estado when 1 then coalesce(tienda_evento.promocion,"") else "" end as promo,
|
||||
curso.temario as csubjects,
|
||||
curso.servicios as cservices,
|
||||
|
||||
lugar.nombre as pname,
|
||||
case when month(evento.fecha_inicio) = month(evento.fecha_fin)
|
||||
then concat("Del ", day(evento.fecha_inicio)," al ",day(evento.fecha_fin)," de ",mi.nombre)
|
||||
else concat("Del ",day(evento.fecha_inicio)," de ",mi.nombre," al ",
|
||||
day(evento.fecha_fin)," de ", mo.nombre)
|
||||
end as date
|
||||
|
||||
day(tienda_evento.fecha_inicio) as dini,
|
||||
day(tienda_evento.fecha_fin) as dend,
|
||||
month(tienda_evento.fecha_inicio) as mini,
|
||||
month(tienda_evento.fecha_fin) as mend
|
||||
|
||||
from evento
|
||||
inner join lugar on evento.lugar_id=lugar.id
|
||||
inner join curso on evento.curso_id=curso.id
|
||||
join mes as mi on mi.id=month(evento.fecha_inicio)
|
||||
join mes as mo on mo.id=month(evento.fecha_fin)
|
||||
where evento.estado=1
|
||||
and evento.id = ?
|
||||
from tienda_evento
|
||||
inner join lugar on tienda_evento.lugar_id=lugar.id
|
||||
inner join curso on tienda_evento.curso_id=curso.id
|
||||
where tienda_evento.estado=1
|
||||
and tienda_evento.id = ?
|
||||
;
|
||||
|
||||
30
lib/Dojo/Model/Data/store/qEstore.q
Executable file
30
lib/Dojo/Model/Data/store/qEstore.q
Executable file
@@ -0,0 +1,30 @@
|
||||
select
|
||||
t.id as tid,
|
||||
c.nombre as nombre,
|
||||
c.subnombre as subnombre,
|
||||
c.descripcion as descripcion,
|
||||
c.maestro as maestro,
|
||||
c.imagen_a as cimga,
|
||||
c.imagen_b as cimgb,
|
||||
c.imagen_c as cimgc,
|
||||
day(t.fecha_inicio) as dini,
|
||||
month(t.fecha_inicio) as mini,
|
||||
day(t.fecha_fin) as dfin,
|
||||
month(t.fecha_fin) as mfin,
|
||||
t.precio as precio,
|
||||
t.promocion as promo,
|
||||
t.promo_estado as promo_estado,
|
||||
t.playera_estado as playera_estado,
|
||||
t.cupo as cupo,
|
||||
l.nombre as lnombre,
|
||||
l.federativa as federativa,
|
||||
l.pais as pais,
|
||||
l.municipio as municipio
|
||||
from tienda_evento as t
|
||||
join curso as c on c.id = t.curso_id
|
||||
join lugar as l on l.id = t.lugar_id
|
||||
|
||||
where t.id=? and t.estado =1
|
||||
;
|
||||
|
||||
|
||||
156
lib/Dojo/Model/Vdgproc.pm
Normal file
156
lib/Dojo/Model/Vdgproc.pm
Normal file
@@ -0,0 +1,156 @@
|
||||
package Dojo::Model::Vdgproc; use Mojo::File 'path';
|
||||
use Mojo::JSON qw(decode_json encode_json);
|
||||
use Dojo::Support qw{month_num2txt log dmph} ;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
|
||||
use File::Basename;
|
||||
use Encode qw(decode_utf8 encode_utf8);
|
||||
use Text::Markdown qw{ markdown };
|
||||
use DBI;
|
||||
use Dojo::Conf;
|
||||
|
||||
sub new { bless {}, shift };
|
||||
my $data_path = path('lib/Dojo/Model/Data')->make_path;
|
||||
#just for fun
|
||||
|
||||
|
||||
sub calendar_monthblock {
|
||||
my $r = _read ($data_path->child("cal/q1Block.q")->slurp);
|
||||
map { $_->{fecha}=month_num2txt($_->{month})." ".$_->{year} } @$r;
|
||||
return $r;
|
||||
}
|
||||
|
||||
sub mtxt {
|
||||
my ($di, $mi, $df, $mf)=@_; # dini,mini,dfin,mfin
|
||||
my $txt;
|
||||
if ($mi == $mf){
|
||||
if ($di == $df){ $txt = "$di de ".month_num2txt($mi);}
|
||||
else{ $txt = "Del $di al $df de ".month_num2txt($mi);}
|
||||
}
|
||||
else{
|
||||
$txt = "Del $di de ".month_num2txt($mi)." al $df de ".month_num2txt($mf);
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
sub calendar_events {
|
||||
my $r = _read ($data_path->child("cal/q3Event.q")->slurp);
|
||||
foreach (@$r) { $_->{fecha} = mtxt( $_->{dini},$_->{mini},$_->{dfin},$_->{mfin}) }
|
||||
return $r;
|
||||
}
|
||||
|
||||
sub event{
|
||||
my ($c,$id)=@_;
|
||||
my $r = shift @{ _read ($data_path->child("event/qEvent.q")->slurp,$id)};
|
||||
$r->{date} = mtxt( $r->{dini},$r->{mini},$r->{dend},$r->{mend});
|
||||
return $r;
|
||||
}
|
||||
|
||||
sub spay {
|
||||
my ($c,$class,$id) = @_;
|
||||
return _read ($data_path->child("/store/qIdStore.q")->slurp,$id)->[0];
|
||||
}
|
||||
|
||||
# 4000004840000008 3, 6, 9, 12, and 18 month installment plans available
|
||||
# "*p4000004840000008
|
||||
# 4242424242424242 No installment plans available.
|
||||
|
||||
#==============================================================================
|
||||
sub store_id {
|
||||
my ($c,$class,$id) = @_;
|
||||
my $r = _read ($data_path->child("/store/qEstore.q")->slurp,$id)->[0];
|
||||
$r->{fecha} = mtxt( $r->{dini},$r->{mini},$r->{dfin},$r->{mfin});
|
||||
return $r;
|
||||
}
|
||||
sub intentCreate{
|
||||
my ($c,$id) = @_;
|
||||
my $q="select t.precio as precio, c.nombre as nombre from tienda_evento as t inner join curso as c on t.curso_id=c.id where t.id = ? ;";
|
||||
return _read ($q,$id)->[0];
|
||||
}
|
||||
sub intentConfirm{
|
||||
my ($c,$id) = @_;
|
||||
my $q="select t.precio as precio, c.nombre as nombre from tienda_evento as t inner join curso as c on t.curso_id=c.id where t.id = ? ;";
|
||||
return _read ($q,$id)->[0];
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
|
||||
# admin evets
|
||||
sub event_del { return _write("delete from evento where id = ?;",pop);}
|
||||
sub course_del{ return _write("delete from curso where id = ?;",pop); }
|
||||
sub place_del { return _write("delete from lugar where id = ?;",pop); }
|
||||
|
||||
sub event_up{
|
||||
my ($self,@bind)=@_;
|
||||
return _write($data_path->child("/admin/event/add/qEup.q")->slurp,@bind);
|
||||
}
|
||||
sub course_up{
|
||||
my ($self,@bind)=@_;
|
||||
return _write($data_path->child("/admin/event/add/qCup.q")->slurp,@bind);
|
||||
}
|
||||
sub place_up{
|
||||
my ($self,@bind)=@_;
|
||||
return _write($data_path->child("/admin/event/add/qPup.q")->slurp,@bind);
|
||||
}
|
||||
sub event_ch{
|
||||
my ($self,@bind)=@_;
|
||||
return _write($data_path->child("/admin/event/change/qEup.q")->slurp,@bind);
|
||||
}
|
||||
sub course_ch{
|
||||
my ($self,@bind)=@_;
|
||||
return _write($data_path->child("/admin/event/change/qCup.q")->slurp,@bind);
|
||||
}
|
||||
sub place_ch{
|
||||
my ($self,@bind)=@_;
|
||||
return _write($data_path->child("/admin/event/change/qPup.q")->slurp,@bind);
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
|
||||
#ayudas =====================================
|
||||
sub tst{
|
||||
|
||||
my $c=shift;
|
||||
my $d=$c->param('n');
|
||||
log("------log-------");
|
||||
log("$d");
|
||||
log("------log-------");
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub _read{
|
||||
my ($q,@bind)=@_;
|
||||
my @empty;
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VDGPROCDB.":".Dojo::Conf::VDGPROCDB_H,Dojo::Conf::VDGPROCDB_UR,Dojo::Conf::VDGPROCDB_URP, {mysql_enable_utf8 => 1});
|
||||
return \@empty unless($dbh);
|
||||
my $h=$dbh->selectall_arrayref($q,{ Slice => {} },@bind)//"error";
|
||||
$dbh->disconnect();
|
||||
#((col1=>d1,col2=>d1),(col1=>d2,col2=>d2))
|
||||
return $h;
|
||||
}
|
||||
|
||||
sub _write{
|
||||
my ($q,@bind)=@_;
|
||||
my (@empty);
|
||||
my $dbh = DBI->connect("DBI:mysql:".Dojo::Conf::VDGPROCDB.":".Dojo::Conf::VDGPROCDB_H,Dojo::Conf::VDGPROCDB_UW,Dojo::Conf::VDGPROCDB_UWP,{mysql_enable_utf8 => 1} );
|
||||
return 0 unless($dbh);
|
||||
my $h=$dbh->do($q,{ Slice => {} },@bind)//"error";
|
||||
$dbh->disconnect();
|
||||
log("db write: $h");
|
||||
return $h;
|
||||
}
|
||||
|
||||
sub load_md{
|
||||
return "" unless
|
||||
my $text = path(shift)->slurp;
|
||||
return markdown( decode_utf8($text) );
|
||||
}
|
||||
|
||||
sub load_txt{
|
||||
return "" unless
|
||||
my $text = path(shift)->slurp;
|
||||
return decode_utf8($text);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -116,7 +116,7 @@ sub contact{
|
||||
my $q="insert into entrada (nombre,correo,pagina,texto,fecha) values(?,?,?,?,now() )" ;
|
||||
my @a=@_;
|
||||
#simple method to ignore spam
|
||||
return _writemsg($q,@a) unless $a[3]=~m/http|website|\<a|feedback|forms|suscribe|advertise|newsletter|promotion|Madam/;
|
||||
return _writemsg($q,@a) unless $a[3]=~m/http|website|\<a|feedback|forms|suscribe|advertise|newsletter|promotion|Madam|Sir/;
|
||||
return 0;
|
||||
}
|
||||
#==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user