コード例 #1
0
ファイル: appform.php プロジェクト: mmendoza000/freekore
    /**
     *@package AppForm
     *@since v0.1 beta
     *@method PrintSearch()
     *@desc  Returns the search Form
     * */
    private function PrintSeach()
    {
        //$fx_find = new ajax('submit', 'pannel-srch-res-'.$this-> IdObject, 'args:op='.encode('search-results').';form:fsrch-'.$this-> IdObject.';url:'.$this->CurrentPage);
        $fx_find = new ajax_submit();
        $fx_find->Args('op=' . encode('search-results'));
        $fx_find->Form('fsrch-' . $this->IdObject);
        $fx_find->ResponseLocation('pannel-srch-res-' . $this->IdObject);
        $fx_find->Url($this->CurrentPage);
        $arrayFields = array();
        foreach ($this->DbRecord->form_fields as $f) {
            if (!isset($this->Labels[$f['Field']])) {
                $this->Labels[$f['Field']] = ucwords(strtolower(strtr($f['Field'], '_', ' ')));
            }
            $arrayFields[$f['Field']] = $this->Labels[$f['Field']];
        }
        //Si hay utilizar la lista existente
        //si no hay SearchByList utilizar el default
        if (count($this->SearchByList) == 0) {
            $this->SearchByList = $arrayFields;
        }
        $sFrm = '<fieldset style="background:#fff;">
<legend>  B&uacute;squeda </legend>
<form id="fsrch-' . $this->IdObject . '" name="fsrch-' . $this->IdObject . '" action="' . $this->CurrentPage . '" method="POST" >
<table border="0"  >
  <tbody>
  <tr>
    <th scope="row">Por:</th>
    <td>
      <select name="srch-by-field" id="src-field">
      <option value="0"> Cualquier campo </option>
      ' . fk_select_options_r($this->SearchByList) . '
      </select>
    </td>
    <td><input id="srcwrd-' . $this->IdObject . '" name="srch-word" type="text"></td>
    <td><input name="srch-btn" type="submit" value="Ir &raquo;" class="btn" > <a href="javascript:void(0)" onclick="$(' . $this->IdObject . ').show();$(\'#pannel-srch-' . $this->IdObject . '\').html(\'\')">Cancelar</a></td>
  </tr>
  </tbody>
</table>
</form>
<div id="pannel-srch-res-' . $this->IdObject . '"></div>
</fieldset><script> $("#srcwrd-' . $this->IdObject . '").focus(); $(' . $this->IdObject . ').hide();</script>' . $fx_find->Render();
        return $sFrm;
    }
コード例 #2
0
 public function importExcelData($file, $tablefields)
 {
     // Test CVS
     set_time_limit(0);
     //require_once 'Excel/reader.php';
     Load::library('phpExcelReader/Excel/reader');
     // ExcelFile($filename, $encoding);
     $data = new Spreadsheet_Excel_Reader();
     // Set output Encoding.
     $data->setOutputEncoding('CP1251');
     /***
      * if you want you can change 'iconv' to mb_convert_encoding:
      * $data->setUTFEncoder('mb');
      *
      **/
     /***
      * By default rows & cols indeces start with 1
      * For change initial index use:
      * $data->setRowColOffset(0);
      *
      **/
     /***
      *  Some function for formatting output.
      * $data->setDefaultFormat('%.2f');
      * setDefaultFormat - set format for columns with unknown formatting
      *
      * $data->setColumnFormat(4, '%.3f');
      * setColumnFormat - set format for column (apply only to number fields)
      *
      **/
     //$data->read(SYSTEM_PATH.'app/libraries/phpExcelReader/RP 030 LG13 0206WM MBA1PR COLOTLAN columnas.xls');
     $data->read($file);
     /*
     
     
     $data->sheets[0]['numRows'] - count rows
     $data->sheets[0]['numCols'] - count columns
     $data->sheets[0]['cells'][$i][$j] - data from $i-row $j-column
     
     $data->sheets[0]['cellsInfo'][$i][$j] - extended info about cell
     
     $data->sheets[0]['cellsInfo'][$i][$j]['type'] = "date" | "number" | "unknown"
     if 'type' == "unknown" - use 'raw' value, because  cell contain value with format '0.00';
     $data->sheets[0]['cellsInfo'][$i][$j]['raw'] = value if cell without format
     $data->sheets[0]['cellsInfo'][$i][$j]['colspan']
     $data->sheets[0]['cellsInfo'][$i][$j]['rowspan']
     */
     error_reporting(E_ALL ^ E_NOTICE);
     echo '<table border="1" class="tbl-1">';
     for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
         if ($i == 1) {
             // HEader
             echo '<thead><tr>';
             echo '<th><input type="checkbox" name="chkAll" id="chkAll" onclick="checkAll($(this),\'chkRow\');" value="all" ></th>';
             for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
                 foreach ($tablefields as $fieldName => $fieldLabel) {
                     $array[$fieldName] = $fieldLabel;
                 }
                 echo "<th>";
                 echo '<select name="col-' . ($j - 1) . '"><option value="">[X]Ignorar</option>' . fk_select_options_r($array) . '</select>';
                 if ($this->display_rules) {
                     echo '<textarea name="rules[]" placeholder="Reglas"></textarea>';
                 }
                 echo "</th>";
             }
             echo '</tr></thead>';
         }
         $trTieneDatos = 0;
         $tr = '<tr>';
         $tr .= '<th><input type="checkbox" class="chkRow" name="rows[]" value="' . $i . '" ></th>';
         for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
             $tr .= '<td>';
             $tr .= utf8_encode($data->sheets[0]['cells'][$i][$j]);
             //$tr .= '<input type="hidden" name="txt_'.$i.'[]" value="'.$data->sheets[0]['cells'][$i][$j].'">';
             $tr .= '<textarea style="display:none" name="txt_' . $i . '[]">' . utf8_encode($data->sheets[0]['cells'][$i][$j]) . '</textarea>';
             $tr .= '</td>';
             if (trim($data->sheets[0]['cells'][$i][$j]) != '') {
                 $trTieneDatos++;
             }
         }
         $tr .= '</tr>';
         if ($trTieneDatos > 0) {
             echo $tr;
         }
     }
     echo '</table>';
     echo '<h3> ' . $data->sheets[0]['numRows'] . ' registros encontrados</h3>';
 }