Esempio 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();
 }
Esempio n. 2
0
 function get_tag($value = null)
 {
     $str_date = new OrMySqlThDate();
     /**
      * Checking $vaule
      */
     if ($value != null) {
         $this->OP_[value]->set($value);
     }
     /**
      * Checking auto_post property
      */
     if ($this->OP_[auto_post]->get()) {
         $this->auto_post();
     }
     $id = $this->get_id_tag();
     $value = $str_date->get_th_str($this->OP_[value]->get());
     //echo "<b>debug</b> ".__FILE__." | ".__LINE__." | value =".$value."<br>";
     if ($value == null) {
         $value = $this->OP_[post_value]->get();
     }
     if ($value == null) {
         $value = $str_date->get_th_str($this->OP_[default_value]->get());
     }
     if ($this->OP_[class_name]->get() == null) {
         $class = null;
     } else {
         $class = 'class="' . $this->OP_[class_name]->get() . '"';
     }
     $this->clip_value($str_date->get_mysql_str($value));
     $type = 'type = "text"';
     $value = 'value="' . $value . '"';
     $title = 'title="' . $this->OP_[title]->get() . '"';
     $this_id = $this->OP_[id]->get();
     $this_format = 'dd/mm/bbbb';
     //$my_value = '<input type="text" name="theDate" readonly="" value="2004/02/02"/>';
     $my_value = "<input {$id} {$class}  {$type} {$value} {$title} maxlength=\"10\" size=\"10\" >" . $this->get_properties_tag();
     $my_value .= '<button title="ปฏิทิน" value="Cal" class="toolbar" type="button" onclick="displayCalendar(document.forms[0].' . $this_id . ',\'' . $this_format . '\',this)" ><img src="../../lib/calendar/image/calendar.png"/></button>';
     //$my_value .= '<input type="button" onclick="displayCalendar(document.forms[0].' . $this_id . ',\'' . $this_format . '\',this)" value="Cal">';
     return $my_value;
 }
Esempio n. 3
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
     }
 }
Esempio n. 4
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;
 }