Diferenças

Aqui você vê as diferenças entre duas revisões dessa página.

Link para esta página de comparações

cinecefa:teste3 [29/55/2016 23:55] (atual)
admin criada
Linha 1: Linha 1:
 +<php>
 +/** @var helper_plugin_sqlite $sqlite */
 +$sqlite = plugin_load('​helper',​ '​sqlite'​);​
 +if(!$sqlite){msg('​This plugin requires the sqlite plugin. Please install it', -1);​return;​}
 +// initialize the database connection
  
 +if(!$sqlite->​init('​data',​DOKU_PLUGIN.'​data/​db/'​)){return;​}
 +// use the plugin
 +//$res = $sqlite->​query("​CREATE TABLE IF NOT EXISTS cinecefasessions (cinecefaid INTEGER PRIMARY KEY, title TEXT, local TEXT,  horario TIME, adata DATE, latitude REAL, longitude REAL, notes TEXT)"​);​
 +//$adata = date("​Y-m-d"​);​
 +$horario = time();
 +
 +//echo "AQUI HO:<br /><​pre>";​
 +//​print_r($_POST);​
 +//echo "</​pre>";​
 +if (count($_POST)>​0) {
 +   if (count($_POST)==1) {
 +     #​pegavalores
 +     $ress = $sqlite->​query("​SELECT * FROM cinecefasessions WHERE cinecefaid="​.$_POST['​cinecefaid'​]);​
 +     ​$ppost = $sqlite->​res2arr($ress);​
 +   } else {
 +     ​$ppost = $_POST;
 +   }
 +   //​checa obrigatorios
 +   ​$title = $ppost['​title'​];​
 +   ​$local = $ppost['​local'​];​
 +   ​$adata = $ppost['​adata'​];​
 +   ​$horario = $ppost['​horario'​];​
 +   ​$latitude = $ppost['​latitude'​];​
 +   ​$longitude = $ppost['​longitude'​]; ​  
 +   ​$notes = $ppost['​notes'​];​
 +   ​print_r($ppost);​
 +}
 +
 +$ress = $sqlite->​query("​SELECT * FROM cinecefasessions ORDER BY adata,​horario DESC"​);​
 +$count = $sqlite->​res2count($ress);​
 +$txt = "";​
 +if ($count>​0) {
 +   $arrr = $sqlite->​res2arr($ress);​
 +   $txt .= "
 +   <​br />
 +   <​span style='​color:​ darkgreen; font-weight:​ bold; font-size: 1.5em'>​
 +Sessões do CEFA cadastradas
 +</​span>​
 +   <​table width='​80%'​ style='​border:​ thin; border-color:​ red;' cellpadding='​5px'>​
 +   <​tr style='​background-color:​ yellow;'​ ><td >​Título</​td><​td>​Local</​td><​td>​Data</​td><​td>​Horário</​td></​tr>";​
 +   ​foreach($arrr as $vv) {
 +      $txt .= "<​tr><​td >"​.$vv['​title'​]."</​td><​td>"​.$vv['​local'​]."</​td><​td>"​.$vv['​adata'​]."</​td><​td>"​.$vv['​horario'​]."</​td>​
 +      <td>
 +      <form method=\"​post\"​ >
 +      <input type=\"​hidden\"​ value=\""​.$vv['​cinecefaid'​]."​\"​ name=\"​cinecefaid\"​ >
 +      <input type=\"​submit\"​ value=\"​editar\"​ >
 +      </​form>​
 +      </td>
 +      </​tr>";​
 +   }
 +   $txt .= "</​table>";​
 +}
 +
 +echo $txt."
 +<br />
 +<span style='​color:​ red; font-weight:​ bold; font-size: 1.5em'>​
 +Criando uma nova edição do Cine CEFA
 +</​span>​
 +<br />
 +<​form ​ method='​post'​ >
 +<table width='​80%'​ cellspacing='​7px'>​
 +<tr>
 +<td align='​right'​ ><​b>​Título da Sessão</​b></​td>​
 +<​td><​input size=50 type=text ​ name=title ​ value='"​.$title."'​ ></​td>​
 +</tr>
 +<tr>
 +<td align='​right'​ ><br />
 +<​b>​Local & endereço</​b>​
 +</td>
 +<​td><​textarea name='​local'​ cols=50 rows=6 >"​.$local."</​textarea></​td>​
 +</tr>
 +<tr>
 +<td align='​right'​ ><​b>​Data</​b></​td>​
 +<​td><​input ​ type='​date' ​ name='​adata'​ value='"​.$adata."'​ ></​td>​
 +</tr>
 +<tr>
 +<td align='​right'​ ><​b>​Horário</​b></​td>​
 +<​td><​input ​ type='​time' ​ name='​horario'​ value='"​.$horario."'​ ></​td>​
 +</tr>
 +<tr>
 +<td align='​right'​ ><​b>​Latitude DD</​b></​td>​
 +<​td><​input type='​number' ​ min=-90.00 ​ max=90.00 step=0.01 name='​latitude'​ value='"​.$latitude."'​ ></​td>​
 +</tr>
 +<tr>
 +<td align='​right'​ ><​b>​Longitude DD</​b></​td>​
 +<​td><​input type='​number' ​ min=-180.00 ​ max=180.00 step=0.01 name=longitude value='"​.$longitude."'​ ></​td>​
 +</tr>
 +<tr>
 +<td align='​right'​ ><​b>​Notas</​b></​td>​
 +<​td><​textarea name='​notes'​ cols=50 rows=6>"​.$notes."</​textarea></​td>​
 +</tr>
 +<tr>
 +<​td>&​nbsp;</​td><​td ><​br/><​input type='​submit'​ value='​Salvar'></​td>​
 +</​table>​
 +</​form>";​
 +</​php>​