function createdetailevents($parenteventid) { $sql = "select * from user_event where id=" . $parenteventid; mysql_query($sql); $handle = mysql_query($sql) or die(mysql_error()); /*$this->db->where('id', $parenteventid); $q = $this->db->get('user_event'); if ($q->num_rows() > 0): $row = $q->row(); endif;*/ $arr; while ($row = mysql_fetch_object($handle)) { $arr["_ID"] = $row->id; $arr["_EventName"] = $row->event_title; $arr["_Location"] = $row->event_loc; $arr["_Description"] = $row->event_desc; $arr["_StartDate"] = $row->start_date; $arr["_EndDate"] = $row->to_date; $arr["_Daily"] = $row->daily; $arr["_Weekly"] = $row->weekly; $arr["_Monthly"] = $row->monthly; $arr["_Yearly"] = $row->yearly; $arr["_Daily_interval"] = $row->daily_interval; $arr["_Weekly_interval"] = $row->weekly_interval; $arr["_Weekly_interval_day"] = $row->weekly_interval_day; $arr["_Monthly_interval"] = $row->monthly_interval; $arr["_Monthly_interval_date"] = $row->monthly_interval_date; $arr["_Yearly_interval_date"] = $row->yearly_interval_date; $arr["_Yearly_interval_month"] = $row->yearly_interval_month; $arr["_Occurence"] = $row->event_occ; $arr["repeat_start_date"] = $row->repeat_start_date; if (trim($arr["_Daily"]) == "0" && trim($arr["_Monthly"]) == "0" && trim($arr["_Weekly"]) == "0" && trim($arr["_Yearly"]) == "0") { $startdate = $arr['_StartDate']; $start_exp = explode("/", $startdate); $arr["_StartDate"] = $start_exp[2] . "-" . $start_exp[1] . "-" . $start_exp[0]; $enddate = $arr['_EndDate']; $end_exp = explode("/", $enddate); $arr["_EndDate"] = $end_exp[2] . "-" . $end_exp[1] . "-" . $end_exp[0]; $strFieldsName = "parenteventid,startDate,endDate"; $strInsertValue = "'" . $arr["_ID"] . "','" . $arr["_StartDate"] . "','" . $arr["_EndDate"] . "'"; $this->insertdetailevent($strFieldsName, $strInsertValue); } else { $startdate = $arr['_StartDate']; $start_exp = explode("/", $startdate); $startdate = $start_exp[2] . "-" . $start_exp[1] . "-" . $start_exp[0]; $enddate = $arr['_EndDate']; $end_exp = explode("/", $enddate); $enddate = $end_exp[2] . "-" . $end_exp[1] . "-" . $end_exp[0]; $repeat_start_date = $arr['repeat_start_date']; $repeat_exp = explode("/", $repeat_start_date); $repeat_start_date = $repeat_exp[2] . "-" . $repeat_exp[1] . "-" . $repeat_exp[0]; $date_difference = strtotime($repeat_start_date) - strtotime($startdate); if (trim($arr["_Daily"]) == "1") { // Start Code $strFieldsName = "parenteventid,startDate,endDate"; $strInsertValue = ""; $arr["_Occurence"] = $date_difference / (60 * 60 * 24); if (trim($arr["_Daily_interval"]) != "") { if (intval($arr["_Daily_interval"]) <= 0) { $arr["_Daily_interval"] = 1; } $icounter = -1; $blnloop = 1; while ($blnloop == 1) { $icounter++; $strInsertValue = "'" . $arr["_ID"] . "'"; $interval = intval(trim($arr["_Daily_interval"])) * $icounter; $startresult = mysql_fetch_array(mysql_query("SELECT ADDDATE('" . $startdate . "', INTERVAL " . $interval . " DAY) as startdate")); $endresult = mysql_fetch_array(mysql_query("SELECT ADDDATE('" . $enddate . "', INTERVAL " . $interval . " DAY) as enddate")); $strNewDate = $startresult['startdate']; $strEndDate = $endresult['enddate']; //$strNewDate=adddays($arr["_StartDate"],(intval(trim($arr["_Daily_interval"]))*$icounter),"day"); //$strEndDate=adddays($arr["_EndDate"],(intval(trim($arr["_Daily_interval"]))*$icounter),"day"); $strInsertValue .= ",'" . $strNewDate . "','" . $strEndDate . "'"; $this->insertdetailevent($strFieldsName, $strInsertValue); if ($icounter + 1 >= intval($arr["_Occurence"])) { $blnloop = 0; } } } // End Code } // weekly if (trim($arr["_Weekly"]) == "1") { $arr["_Occurence"] = $date_difference / (60 * 60 * 24 * 7); // Start Code $strFieldsName = "parenteventid,startDate,endDate"; $strInsertValue = ""; if (trim($arr["_Weekly_interval"]) == "") { $startdate = $arr['_StartDate']; $start_exp = explode("/", $startdate); $arr["_StartDate"] = $start_exp[2] . "-" . $start_exp[1] . "-" . $start_exp[0]; $arr["_Weekly_interval"] = getCurrentWeeklyDay($arr["_StartDate"]); } if (trim($arr["_Weekly_interval"]) != "") { $icounter = -1; $blnloop = 1; $strNewDate = ""; $strNewEndDate = ""; $startdate = $arr['_StartDate']; $start_exp = explode("/", $startdate); $arr["_StartDate"] = $start_exp[2] . "-" . $start_exp[1] . "-" . $start_exp[0]; $enddate = $arr['_EndDate']; $end_exp = explode("/", $enddate); $arr["_EndDate"] = $end_exp[2] . "-" . $end_exp[1] . "-" . $end_exp[0]; while ($blnloop == 1) { $strInsertValue = "'" . $arr["_ID"] . "'"; $icounter++; if ($icounter == 0) { $strNewDate = getWeeklyDay($arr["_StartDate"], trim($arr["_Weekly_interval"])); } else { $intWeekInterval = 1; if (trim($arr["_Weekly_interval_day"]) != "") { $intWeekInterval = intval(trim($arr["_Weekly_interval_day"])); } if ($intWeekInterval <= 0) { $intWeekInterval = 1; } $strNewDate = adddays($strNewDate, $intWeekInterval, "week"); } $arrTempCompare = getDateDifference($arr["_StartDate"], $strNewDate); $strNewEndDate = adddays($arr["_EndDate"], intval($arrTempCompare["days"]), "day"); $exp_new = explode("-", $strNewDate); if (strlen($exp_new[2]) == 1) { $exp_new[2] = "0" . $exp_new[2]; } $exp_newend = explode("-", $strNewEndDate); if (strlen($exp_newend[2]) == 1) { $exp_newend[2] = "0" . $exp_newend[2]; } $strNewDate = $exp_new[0] . "-" . $exp_new[1] . "-" . $exp_new[2]; $strNewEndDate = $exp_newend[0] . "-" . $exp_newend[1] . "-" . $exp_newend[2]; $strInsertValue .= ",'" . $strNewDate . "','" . $strNewEndDate . "'"; $this->insertdetailevent($strFieldsName, $strInsertValue); if ($icounter + 1 >= intval($arr["_Occurence"])) { $blnloop = 0; } } } // End Code } // Monthly if (trim($arr["_Monthly"]) == "1") { // Start Code $arr["_Occurence"] = $date_difference / (60 * 60 * 24 * 30); $strFieldsName = "parenteventid,startDate,endDate"; $strInsertValue = ""; $startdate = $arr['_StartDate']; $start_exp = explode("/", $startdate); $arr["_StartDate"] = $start_exp[2] . "-" . $start_exp[1] . "-" . $start_exp[0]; $enddate = $arr['_EndDate']; $end_exp = explode("/", $enddate); $arr["_EndDate"] = $end_exp[2] . "-" . $end_exp[1] . "-" . $end_exp[0]; if (trim($arr["_Monthly_interval"]) == "") { $arr["_Monthly_interval"] = getCurrentMonthDay($arr["_StartDate"]); } if (trim($arr["_Monthly_interval"]) != "") { $icounter = -1; $blnloop = 1; $strNewDate = ""; while ($blnloop == 1) { $strInsertValue = "'" . $arr["_ID"] . "'"; $icounter++; $intMonthInterval = 1; if (trim($arr["_Monthly_interval_date"]) != "") { $intMonthInterval = intval(trim($arr["_Monthly_interval_date"])); } if ($intMonthInterval <= 0) { $intMonthInterval = 1; } if ($icounter == 0) { $strNewDate = getMonthDay($arr["_StartDate"], trim($arr["_Monthly_interval"]), $intMonthInterval, 1); } else { $strNewDate = getMonthDay($strNewDate, trim($arr["_Monthly_interval"]), $intMonthInterval); } if ($strNewDate != "") { $arrTempCompare = getDateDifference($arr["_StartDate"], $strNewDate); $strNewEndDate = adddays($arr["_EndDate"], intval($arrTempCompare["days"]), "day"); $exp_new = explode("-", $strNewDate); if (strlen($exp_new[2]) == 1) { $exp_new[2] = "0" . $exp_new[2]; } $exp_newend = explode("-", $strNewEndDate); if (strlen($exp_newend[2]) == 1) { $exp_newend[2] = "0" . $exp_newend[2]; } $strNewDate = $exp_new[0] . "-" . $exp_new[1] . "-" . $exp_new[2]; $strNewEndDate = $exp_newend[0] . "-" . $exp_newend[1] . "-" . $exp_newend[2]; $strInsertValue .= ",'" . $strNewDate . "','" . $strNewEndDate . "'"; $this->insertdetailevent($strFieldsName, $strInsertValue); } if ($icounter + 1 >= intval($arr["_Occurence"])) { $blnloop = 0; } } } // End Code } // Yearly if (trim($arr["_Yearly"]) == "1") { // Start Code $arr["_Occurence"] = $date_difference / (60 * 60 * 24 * 365); $startdate = $arr['_StartDate']; $start_exp = explode("/", $startdate); $arr["_StartDate"] = $start_exp[2] . "-" . $start_exp[1] . "-" . $start_exp[0]; $enddate = $arr['_EndDate']; $end_exp = explode("/", $enddate); $arr["_EndDate"] = $end_exp[2] . "-" . $end_exp[1] . "-" . $end_exp[0]; // Start Code $strFieldsName = "parenteventid,startDate,endDate"; $strInsertValue = ""; if (trim($arr["_Yearly_interval_date"]) == "" && intval(trim($arr["_Yearly_interval_date"])) <= 0) { $arr["_Yearly_interval_date"] = getCurrentMonth($arr["_StartDate"]); } if (trim($arr["_Yearly_interval_month"]) == "" && intval(trim($arr["_Yearly_interval_month"])) <= 0) { $arr["_Yearly_interval_month"] = getCurrentMonthDay($arr["_StartDate"]); } if (trim($arr["_Yearly_interval_month"]) != "") { $icounter = -1; $blnloop = 1; $strNewDate = ""; while ($blnloop == 1) { $strInsertValue = "'" . $arr["_ID"] . "'"; $icounter++; if ($icounter == 0) { $strNewDate = getYearDay($arr["_StartDate"], trim($arr["_Yearly_interval_date"]), trim($arr["_Yearly_interval_month"]), 1); } else { $strNewDate = getYearDay($strNewDate, trim($arr["_Yearly_interval_date"]), trim($arr["_Yearly_interval_month"])); } if ($strNewDate != "") { $arrTempCompare = getDateDifference($arr["_StartDate"], $strNewDate); $strNewEndDate = adddays($arr["_EndDate"], intval($arrTempCompare["days"]), "day"); $exp_new = explode("-", $strNewDate); if (strlen($exp_new[2]) == 1) { $exp_new[2] = "0" . $exp_new[2]; } $exp_newend = explode("-", $strNewEndDate); if (strlen($exp_newend[2]) == 1) { $exp_newend[2] = "0" . $exp_newend[2]; } $strNewDate = $exp_new[0] . "-" . $exp_new[1] . "-" . $exp_new[2]; $strNewEndDate = $exp_newend[0] . "-" . $exp_newend[1] . "-" . $exp_newend[2]; $strInsertValue .= ",'" . $strNewDate . "','" . $strNewEndDate . "'"; $this->insertdetailevent($strFieldsName, $strInsertValue); } if ($icounter + 1 >= intval($arr["_Occurence"])) { $blnloop = 0; } } } // End Code } } } }
$gas1 = $_POST['gas1']; $gas2 = $_POST['gas2']; $gas3 = $_POST['gas3']; $gas4 = $_POST['gas4']; $gas5 = $_POST['gas5']; $gas6 = $_POST['gas6']; $gas7 = $_POST['gas7']; $gas8 = $_POST['gas8']; $gas9 = $_POST['gas9']; $gas10 = $_POST['gas10']; $gas11 = $_POST['gas11']; $gas12 = $_POST['gas12']; $gas13 = $_POST['gas13']; $electricity = $_POST['electricity']; //电的消耗量 $month_day = getMonthDay($data_month, $data_year); //获得当前月份的天数 $_SESSION['modify_date'] = $modify_date; $cold_equival_value = 0.03412 * $cold_quantity; //冷量当量折标 $cold_indiff_value = 0.03412 * $cold_quantity; //冷量等价折标 $steam_equival_value = 0.1286 * $steam; //蒸汽当量折标 $steam_indiff_value = 0.1286 * $steam; //蒸汽等价折标 $electricity_equival_value = 0.1229 * $electricity; //电的当量折标 $electricity_indiff_value = 4.04 * $electricity; //电的等价折标 $daily_data_coal = $coal1 + $coal2 + $coal3 + $coal4 + $coal5;