Exemplo n.º 1
0
 function get_format($value)
 {
     $val = array();
     switch ($this->OP_[type]->get()) {
         case "currency":
             $this->OP_[value]->set(number_format($value, $this->OP_[option]->get()));
             break;
         case "th_date":
             if ($value > 0) {
                 if ($this->OP_[option]->get() == "as400") {
                     $val["th_year"] = substr($value, 0, 4);
                     $val["mon"] = substr($value, 4, 2);
                     $val["mday"] = substr($value, 6, 2);
                     $this->OP_[value]->set($val["mday"] . "/" . $val["mon"] . "/" . $val["th_year"]);
                 } else {
                     if ($this->OP_[option]->get() == "mysql") {
                         $my_date = new OrMySqlThDate($value);
                         $this->OP_[value]->set($my_date->get_th_str());
                     } else {
                         if ($this->OP_[option]->get() == "mysql_t") {
                             $my_date = new OrMySqlThDatetime($value);
                             $this->OP_[value]->set($my_date->get_th_str());
                         } else {
                             die('กรุณาระบุประเภท[ as400 | mysql | mysql_t ' . $this->OP_[type]->get() . ' กรุณาตรวจสอบคำสั่ง');
                         }
                     }
                 }
             } else {
                 /*กรณีไม่มีข้อมูลให้แสดงเป็น "-" สุชาติ 8/9/2548*/
                 $this->OP_[value]->set("-");
             }
             break;
         case "hn":
             if ($value > 100) {
                 $hn = $value / 100;
                 $hn = sprintf("%.2f", $hn);
                 $value = str_replace('.', '-', $hn);
                 $this->OP_[value]->set($value);
             }
             break;
         default:
             $this->OP_[value]->set(sprintf($this->OP_[type]->get(), $value));
     }
     return $this->OP_[value]->get();
 }
Exemplo n.º 2
0
 function get_filter_value($value)
 {
     if (!is_numeric($value)) {
         /*ตรวจสอบการเป็นข้อมูลวันที่เวลาไทยหรือไม่*/
         $mysql_th_datetime = new OrMySqlThDatetime($value);
         if ($mysql_th_datetime->is_datetime) {
             return $mysql_th_datetime->get_mysql_str();
         } else {
             $mysql_th_date = new OrMySqlThDate($value);
             if ($mysql_th_date->is_date) {
                 return $mysql_th_date->get_mysql_str();
             } else {
                 return AddSlashes($value);
             }
         }
     } else {
         return AddSlashes($value);
         // แก้ไขกรณีบันทึกเลข ทศนิยม สุชาติ บุญหชัยรัตน์  14/10/2547
     }
 }
Exemplo n.º 3
0
 function get_sql_value($id)
 {
     /* เช็คประเภทของข้อมูล */
     if (!is_numeric($this->val_controls[db_field][$id])) {
         /* ตรวจสอบการเป็นข้อมูลวันที่เวลาไทยหรือไม่ */
         $mysql_th_datetime = new OrMySqlThDatetime($this->val_controls[db_field][$id]);
         if ($mysql_th_datetime->is_datetime) {
             return "'" . $mysql_th_datetime->get_mysql_str() . "'";
         } else {
             $mysql_th_date = new OrMySqlThDate($this->val_controls[db_field][$id]);
             if ($mysql_th_date->is_date) {
                 return "'" . $mysql_th_date->get_mysql_str() . "'";
             } else {
                 return "'" . AddSlashes($this->val_controls[db_field][$id]) . "'";
             }
         }
     } else {
         return "'" . AddSlashes($this->val_controls[db_field][$id]) . "'";
         // แก้ไขกรณีบันทึกเลข ทศนิยม สุชาติ บุญหชัยรัตน์  14/10/2547
     }
     //return null;
 }