示例#1
0
文件: RadioList.php 项目: spinit/osy
 protected function build()
 {
     $a_val = array();
     if ($val = $this->get_par('values')) {
         $a_val_raw = explode(',', $val);
         foreach ($a_val_raw as $k => $val) {
             $a_val[] = explode('=', $val);
         }
     }
     if ($sql = $this->get_par('datasource-sql')) {
         $sql = HelperOsy::replaceVariable($sql);
         $sql = HelperOsy::parseString($sql);
         $a_val = $this->db->exec_query($sql, null, 'NUM');
     }
     $dir = $this->get_par('direction');
     foreach ($a_val as $k => $val) {
         //$tr = $this->add(tag::create('tr'));
         //$tr->add(tag::create('td'))->add('<input type="radio" name="'.$this->id.'" value="'.$val[0].'"'.(!empty($_REQUEST[$this->id]) && $_REQUEST[$this->id] == $val[0] ? ' checked' : '').'>');
         //$tr->add(tag::create('td'))->add($val[1]);
         $rd = new RadioBox($this->id);
         $rd->value = $val[0];
         if ($this->cols) {
             $rst = $k % $this->cols;
             if (empty($rst)) {
                 $row += 10;
             }
             $col = $resto * 10 + 10;
             $this->put(null, $rd . '&nbsp;' . $val[1], $row, $col);
         } elseif ($dir == 'O') {
             $this->put(null, $rd . '&nbsp;' . $val[1], 10, $k * 10 + 9);
         } else {
             $this->put(null, $rd . '&nbsp;' . $val[1], $k * 10 + 9, 10);
         }
         //$this->put(null,$val[1],$k+9,10);
     }
     parent::build();
 }
示例#2
0
文件: DataView.php 项目: spinit/osy
 protected function excelBuild($sql)
 {
     $sql = HelperOsy::parseString($sql);
     require_once OSY_PATH_LIB_EXT . '/phpexcel-1.8.0/PHPExcel.php';
     require_once OSY_PATH_LIB_EXT . '/phpexcel-1.8.0/PHPExcel/Writer/Excel2007.php';
     $sql = HelperOsy::replaceVariable($sql);
     $sql = HelperOsy::parseString($sql);
     if (!empty($_REQUEST['osy']['tid'])) {
         $sql = "SELECT a.* \n                    FROM ({$sql}) a \n                    WHERE a.\"_tab\" = '{$_REQUEST['osy']['tid']}'\n                    ORDER BY 1";
         //mail('*****@*****.**','errore',$sql);
     }
     $rs = env::$dba->exec_query($sql, null, 'ASSOC');
     $exc = new PHPExcel();
     $exc->getProperties()->setCreator("Service Portal");
     $exc->getProperties()->setLastModifiedBy("Service Portal");
     $exc->getProperties()->setTitle("Order export");
     $exc->getProperties()->setSubject("Order export");
     $exc->getProperties()->setDescription("Esportazione ordini generata dal Service Portal");
     $letters = array_unshift(range('A', 'Z'), '');
     $cell = '';
     function calc_pos($n)
     {
         $l = range('A', 'Z');
         if ($n <= 26) {
             return $l[$n - 1];
         }
         $r = $n % 26;
         $i = ($n - $r) / 26 - (empty($r) ? 1 : 0);
         return calc_pos($i) . (!empty($r) ? calc_pos($r) : 'Z');
     }
     for ($i = 0; $i < count($rs); $i++) {
         $j = 0;
         foreach ($rs[$i] as $k => $v) {
             if ($k[0] == '_') {
                 continue;
             }
             $col = calc_pos($j + 1);
             $cel = $col . ($i + 2);
             try {
                 if (empty($i)) {
                     $exc->getActiveSheet()->SetCellValue($col . ($i + 1), str_replace(array('_X', '!'), '', strtoupper($k)));
                 }
                 $exc->getActiveSheet()->SetCellValue($cel, str_replace('<br/>', ' ', $v));
             } catch (Exception $e) {
             }
             $j++;
         }
     }
     $exc->getActiveSheet()->setTitle('Ordini');
     $objWriter = new PHPExcel_Writer_Excel2007($exc);
     $filename = OSY_PATH_VAR . '/tmp/' . str_replace(' ', '-', strtolower($this->__par['form-title'])) . date('-Y-m-d-H-i-s') . '.xlsx';
     $objWriter->save($filename);
     die(str_replace(OSY_PATH_VAR, '/var', $filename));
 }