]> git.llucax.com Git - mecon/intranet.git/blobdiff - sistema/www/noticias.php
Ahora tiene 2 tablas para las noticias desacomodadas
[mecon/intranet.git] / sistema / www / noticias.php
index 0ffde4d364fb469a409f8e100da719cf2f8cc373..90f53319c8d719ac07bc338a081fc5fa7ca5df38 100644 (file)
      ?>
     </td>
     <td width='600'>
      ?>
     </td>
     <td width='600'>
-      <? include 'noticias.htm'?>
+    <?
+       require_once '../../lib/noticia.php';
+       require_once '../local_lib/HTML_Noticia.php';
+       require_once '../../lib/mecondavdb.php';
+       $db = MEconDAVDB::Connect();
+       $hoy = new Date();
+       $fecha_nuevo  = $hoy->format('%Y-%m-%d');
+       $hoy->subtractSeconds(60*60*24*7);//7 dias
+       $fecha_limite = $hoy->format('%Y-%m-%d');
+       $query = "SELECT Articles.article_id,
+                        IF(Articles.publication_date > '$fecha_nuevo', 'NUEVA', null)
+                 FROM Articles, ArticlePublicationStates
+                WHERE Articles.article_publication_state_id =
+                       ArticlePublicationStates.article_publication_state_id
+                AND ArticlePublicationStates.publication_state_id=5
+                AND Articles.publication_date > '$fecha_limite' 
+                ORDER BY Articles.publication_date desc";
+       $result = $db->query($query);
+       if(DB::isError($result))
+         die($result->getMessage("query mal hecho"));
+       $ht1 = new HTML_Table(array('width'=>'300', 'border'=>'0', 'cellspacing'=>'0', 'cellpadding' => '0'));
+       $ht2 = new HTML_Table(array('width'=>'300', 'border'=>'0', 'cellspacing'=>'0', 'cellpadding' => '0'));
+       $impar = true;
+       while($row = $result->fetchRow())
+       {
+         $n = new noticia($row[0]);
+         $not = new HTML_Noticia($n);
+        if($row[1] == 'NUEVA')
+             $not->setNuevo(true);
+        if($impar)
+        {
+          $impar = false;
+           $ht1->addRow(array($not));
+        }
+        else
+        {
+          $impar = true;
+           $ht2->addRow(array($not));
+        }
+       }
+       $ht = new HTML_Table(array('width'=>'300', 'border'=>'0', 'cellspacing'=>'0', 'cellpadding' => '0'));
+       $ht->addRow(array($ht1,$ht2));
+       $ht->display();
+    ?>
     </td>
   </tr>
 </table>
     </td>
   </tr>
 </table>