Example #1
0
 function renderTxt()
 {
     $date = date('Y-m-d');
     if ($this->query('date')) {
         $post = $this->query();
         $date = $post['date']['Y'] . '-' . $post['date']['M'] . '-' . $post['date']['d'];
     }
     // Ensures that PEAR uses correct config file.
     PEAR_Config::singleton(PATH_ROOT . '.pearrc');
     $this->db->query("SELECT tilmelding.id, tilmelding.dato_slut\n            FROM langtkursus_tilmelding tilmelding\n                INNER JOIN langtkursus ON langtkursus.id = tilmelding.kursus_id\n                INNER JOIN adresse ON tilmelding.adresse_id = adresse.id\n            WHERE\n                ((tilmelding.dato_slut > langtkursus.dato_slut AND tilmelding.dato_start < DATE_ADD('{$date}', INTERVAL 3 DAY) AND tilmelding.dato_slut > NOW())\n                OR (tilmelding.dato_slut <= langtkursus.dato_slut AND tilmelding.dato_start < DATE_ADD('{$date}', INTERVAL 3 DAY) AND tilmelding.dato_slut > '{$date}')\n                OR (tilmelding.dato_slut = '0000-00-00' AND langtkursus.dato_start < DATE_ADD('{$date}', INTERVAL 3 DAY) AND langtkursus.dato_slut > '{$date}'))\n                AND tilmelding.active = 1\n            ORDER BY adresse.fornavn ASC, adresse.efternavn ASC");
     $list = array();
     $i = 0;
     while ($this->db->nextRecord()) {
         $t = new VIH_Model_LangtKursus_Tilmelding($this->db->f('id'));
         // strange way to do it, but only way to get the header match data!
         $list[$i][3] = $t->get('navn');
         $list[$i][5] = $t->get('email');
         $list[$i][6] = $t->get('adresse');
         $list[$i][7] = $t->get('postby');
         $list[$i][8] = $t->get('postnr');
         $list[$i][11] = $t->get('telefon');
         // $list[$i][10] = $t->get('nationalitet');
         $list[$i][13] = $t->get('mobil');
         $i++;
     }
     $address_book = new Contact_AddressBook();
     $csv_builder = $address_book->createBuilder('csv_wab');
     if (PEAR::isError($csv_builder)) {
         throw new Exception('CSV_builder error: ' . $csv_builder->getUserInfo());
     }
     $result = $csv_builder->setData($list);
     if (PEAR::isError($result)) {
         throw new Exception('CSV_builder data error: ' . $result->getUserInfo());
     }
     // @todo some error in the build. It has been traced back to getConfig();
     $result = $csv_builder->build();
     if (PEAR::isError($result)) {
         throw new Exception('CSV_builder build error: ' . $result->getUserInfo());
     }
     // This could be nice, but there is an error in the method!
     // echo $csv_builder->download('holdliste');
     // instead the following should do the job!
     if (headers_sent()) {
         throw new Exception('Cannot process headers, headers already sent');
     }
     $filename = 'holdliste.csv';
     if (Net_UserAgent_Detect::isIE()) {
         // IE need specific headers
         header('Content-Disposition: inline; filename="' . $filename . '"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Pragma: no-cache');
     }
     header('Content-Type: ' . $csv_builder->mime);
     return $csv_builder->result;
 }
Example #2
0
function form_button($text, $img = null, $name = null, $value = '1', $class = null, $type = 'submit')
{
    $attributes['type'] = $type;
    if ($class !== null) {
        $attributes['class'] = $class;
    }
    if (Net_UserAgent_Detect::isIE()) {
        # Hack to work around IE bug with form buttons. IE has really, really
        # stupid handling of <button> tags, which makes them unusable. On the
        # other side, <input> tags reserves the value= attribute for the text
        # that appers inside the button, so we have to encode both name and
        # value in the name of the button.
        if ($name !== null) {
            $attributes['name'] = $name . '_v[' . $value . ']';
        }
        $attributes['value'] = $text;
        return txttag('input', $attributes);
    } else {
        # Here we use the new <button> tag, which is much more powerful and
        # is compatible with
        if ($name !== null) {
            $attributes['name'] = $name;
            $attributes['value'] = $value;
        }
        $contents = "";
        if ($img !== null) {
            $contents .= txttag('img', array('alt' => '', 'class' => 'button-img', 'src' => 'img/' . $img));
        }
        $contents .= txttag('span', array('class' => 'button-text'), escape($text));
        return txttag('button', $attributes, $contents);
    }
}
Example #3
0
File: p4a.php Project: eliudiaz/p4a
 /**
  * @return array
  */
 private function detectClient()
 {
     require_once dirname(dirname(__FILE__)) . '/libraries/pear_net_useragent_detect.php';
     Net_UserAgent_Detect::detect();
     if (P4A_FORCE_HANDHELD_RENDERING) {
         $this->browser = self::BROWSER_HANDHELD;
     } elseif (Net_UserAgent_Detect::isIE()) {
         $this->browser = self::BROWSER_IE;
     } elseif (Net_UserAgent_Detect::isBrowser('gecko')) {
         $this->browser = self::BROWSER_GECKO;
     } elseif (Net_UserAgent_Detect::isBrowser('safari')) {
         $this->browser = self::BROWSER_SAFARI;
     } elseif (Net_UserAgent_Detect::isBrowser('opera')) {
         $this->browser = self::BROWSER_OPERA;
     } else {
         $this->browser = self::BROWSER_HANDHELD;
     }
     foreach (Net_UserAgent_Detect::_getStaticProperty('os') as $os => $detected) {
         if ($detected) {
             if (preg_match("/^win.*\$/", $os)) {
                 $this->browser_os = self::BROWSER_WINDOWS;
             } elseif (preg_match("/^mac.*\$/", $os)) {
                 $this->browser_os = self::BROWSER_MAC;
             }
             break;
         }
     }
     return Net_UserAgent_Detect::_getStaticProperty('browser');
 }