/home/banprang/domains/plai.go.th/public_html/coremain/function_form.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php

// ########################## selected_field_sql ########################
/*
 *  function selected_field_sql
 *  input $fname = name of selected form
 *  $sql = full data sql for query
 *  $value_field = name in field in query in will be value of option
 *  $name_field = name of field that show in option
 *  $default(optional) = default values that selected
 *  $first_info_text(optional) = text_info before selected
 *  $first_info_value (optional) = values of first_info_text 
 */

function selected_field_sql($fname$sql$value_field$name_field$default NULL$first_info_text NULL$first_info_value NULL) {

  
$result mysql_query($sql);

  echo 
"<select name=\"$fname\">";
  if (!empty(
$first_info_text)) {
    if (
$data[$value_field] == $first_info_value)
      echo 
"<option value=\"first_info_value\" selected=\"selected\">$first_info_text</option>";
    else
      echo 
"<option value=\"first_info_value\">$first_info_text</option>";
  }
  while (
$data mysql_fetch_array($result)) {
    if (
$data[$value_field] == $default)
      echo 
"<option value=\"$data[$value_field]\" selected=\"selected\">$data[$name_field]</option>";
    else
      echo 
"<option value=\"$data[$value_field]\">$data[$name_field]</option>";
  }
  echo 
"</selected>";
  
mysql_close($handle);
  return;
}


function 
getGProcurement($url$id_home) {
  
//if ($param == '1' && (date('H') == '12' || date('H') == '17')) {
  
if (date('H') == 12 || date('H') > 16 || date('H') < 9) {
    
$xml = @simplexml_load_file($url);
    if(
$xml){
      
$del_today "DELETE FROM `cms_egprss` Where id_home = '$id_home'";
      
mysql_query($del_today);
      
      
$ArrayDocument = array();
      foreach(
$xml->children() as $key =>$value){
        
$ArrayDocument= array('channel' => $value);    
      }

      
$today Date('Y-m-d');
      if (isset(
$ArrayDocument[$today])) {
        
krsort($ArrayDocument[$today]);
        
$CenterDocDLA['today'] = $ArrayDocument[$today];
        unset(
$ArrayDocument[$today]);
      }
      
$CenterDocDLA['all'] = $ArrayDocument;
  
//    debuga($CenterDocDLA['all']);
      
$arrItem = [];
      foreach (
$CenterDocDLA['all'] as $key => $value) {

        
$arrData['egp_title'] = $value->title;
        
$arrData['egp_description'] = $value->description;
        
$arrData['egp_date'] = $value->lastBuildDate;
        
$arrItem $value->item;
      }
  
//    debuga($arrData);

      
$_egp select_max_query0('egp_id''cms_egprss');//, 'title_id', $title_id);
      
$egp_id $_egp[0] == '' $_egp[0];
      foreach (
$arrItem as $keyrss => $valuerss) {
        
$arrData['egp_id'] = $egp_id;
        
$arrData['egp_rss_title'] = $valuerss->title;
        
$arrData['egp_rss_link'] = $valuerss->link;
        
$arrData['egp_rss_pub_date'] = $valuerss->pubDate;
        
$arrData['id_home'] = $id_home;

        
$colData implode(','array_keys($arrData));
        
$textData "('".implode("','"$arrData)."')";
        
$insert "insert into cms_egprss ($colData) values $textData";
        
mysql_query($insert);
        ++
$egp_id;
      }
    }
  }
}

?>