$v){ $row_no = $k+1; if($row_no<$START_ROW){continue;} $a = explode("\t",$v); $NAME = $a[3]; $TIME = $a[0]; $HOLIDAY = $a[4]; $student_email = $a[1]; $class_area = $a[7]; $result = trim($a[10]); $is_valid_result = in_array($result, $ary_valid_result); #var_dump($is_valid_result);var_dump($result); if(!$is_valid_result){continue;} if($wpdb->get_row('SELECT row_no FROM '.$TBL.' WHERE row_no='.$row_no)){continue;} $email_content = ''; $subject=''; #echo $NAME.'-'.$TIME.'-'.$HOLIDAY.'-'.$result."
";continue; #debug if(in_array($result, $ary_approval_result)){ if(!$approval_email_content){ $post = get_page(APPROVAL_HOLIDAY_PAGE_ID); $approval_email_content = $post->post_content; $approval_subject = $post->post_title; } $email_content = $approval_email_content; $subject = $approval_subject; }else if(in_array($result, $ary_reject_result)){ if(!$reject_email_content){ $post = get_page(REJECT_HOLIDAY_PAGE_ID); $reject_email_content = $post->post_content; $reject_subject = $post->post_title; } $email_content = $reject_email_content; $subject = $reject_subject; } $cc = 'hi'; if(strpos($class_area,'新竹')!==false){$cc='hc';} if(strpos($class_area,'台中')!==false){$cc='tc';} if(strpos($class_area,'南')!==false || strpos($class_area,'高雄')!==false){$cc='st';} $cc.='@sted.tw'; // send mail foreach(array('NAME','HOLIDAY','TIME')as$var){ $email_content = str_replace('{'.$var.'}', $$var, $email_content); } $email_content = nl2br($email_content).'
'.$cc; $ary_email = array($student_email, $cc); #$ary_email = array('vansindata@gmail.com');#debug; send_mail_base($ary_email, $subject, $email_content, $cc, '台灣人工智慧學校'); // save database $ary_insert = array('row_no'=>$row_no, 'log_result'=>$result, 'log_datetime'=>$now,'username'=>$NAME); $wpdb->insert($TBL, $ary_insert); echo 'Done '.$row_no. $NAME.'
'; } echo '
ALL Done';