<?php
include('D:\\Wapp\\apache2\\htdocs\\xyz.pl\\misc\\3.php');
include('D:\\Wapp\\apache2\\htdocs\\xyz.pl\\misc\\functions.php');
require_once('D:\\Wapp\\apache2\\htdocs\\xyz.pl\\misc\\class.phpmailer.php');
require_once('D:\\Wapp\\apache2\\htdocs\\xyz.pl\\misc\\class.smtp.php');
$xmlPotentials=simplexml_load_file('D:\\Wapp\\apache2\\htdocs\\xyz.pl\\language\\pl\\potentials.xml');
if($argc>1)
switch($_GET["parameter1"])
{
case "m":
//mailSend
$tempMails=$dbMaster->query(
"
SELECT
*
FROM
fl_mail
INNER JOIN fl_user ON user_id = mail_recipient_userid
WHERE
mail_issent = false
")->fetchAll(PDO::FETCH_ASSOC);
foreach($tempMails as $mailRow)
{
$mail =new PHPMailer();
$mail->SetLanguage("pl");
$mail->IsSMTP(); // send via SMTP
$mail->CharSet ="UTF-8";
$mail->Host ="192.168.1.5"; // SMTP servers
$mail->SMTPAuth=false; // turn on SMTP authentication
$mail->Port =25;
switch($mailRow["mail_senderid"])
{
case 1:
$mail->From ="it@xyz.pl";
$mail->FromName="xyz";
break;
case 2:
$mail->From ="office.plwa@xyz.pl";
$mail->FromName="xyze";
break;
default:
$mail->From ="it@xyz.pl";
$mail->FromName="xyz";
break;
}
$mail->AddAddress($mailRow["user_mail"]);
$mail->WordWrap=80; // set word wrap
$mail->IsHTML(true); // send as HTML?
$mail->Subject =$mailRow["mail_subject"];
$mail->Body =$mailRow["mail_body"];
if($mailRow["mail_senderid"]<0)
{
$tempMailIsSent=$dbMaster->query(
"
UPDATE fl_mail
SET
mail_issent = true,
mail_sent_datetime = 'n/a'
WHERE
mail_id = ".$mailRow["mail_id"]."
");
}
else
{
$mail->Send();
$tempMailIsSent=$dbMaster->query(
"
UPDATE fl_mail
SET
mail_issent = true,
mail_sent_datetime = '".date("Y-m-d H:i:s")."' WHERE
mail_id = ".$mailRow["mail_id"]."
");
}
}
//mealReminder
{
$mealOrder =$dbMaster->query(
"
SELECT
*
FROM
fl_meal_order
WHERE
meal_order_delivery_datetime = '".date("Y-m-d")."' AND meal_order_statusid = 1
")->fetchAll(PDO::FETCH_ASSOC);
$tempSubject=$xmlPotentials->functions->office->subfunctions->meals72->orderNotification->noPaymentReminder->subject;
$tempBody =$xmlPotentials->functions->office->subfunctions->meals72->orderNotification->newMeal->header1;
$tempBody.="<br/>";
$tempBody.="<br/>";
$tempBody.=$xmlPotentials->functions->office->subfunctions->meals72->orderNotification->noPaymentReminder->body1;
$tempBody.="<br/>";
$tempBody.="<br/>";
$tempBody.=str_replace("br","<br/>",$xmlPotentials->functions->office->subfunctions->meals72->orderNotification->footer1);
foreach($mealOrder as $rowOrder)
{
sendMail($tempSubject,$tempBody,$rowOrder["meal_order_userid"]);
}
}
{
$mealOrder =$dbMaster->query(
"
SELECT
*
FROM
fl_meal_order
WHERE
meal_order_delivery_datetime = '".date("Y-m-d")."' AND meal_order_statusid = 1
")->fetchAll(PDO::FETCH_ASSOC);
$tempSubject=$xmlPotentials->functions->office->subfunctions->meals72->orderNotification->noPaymentReminder->subject;
$tempBody =$xmlPotentials->functions->office->subfunctions->meals72->orderNotification->newMeal->header1;
$tempBody.="<br/>";
$tempBody.="<br/>";
$tempBody.=$xmlPotentials->functions->office->subfunctions->meals72->orderNotification->noPaymentReminder->body2;
$tempBody.="<br/>";
$tempBody.="<br/>";
$tempBody.=str_replace("br","<br/>",$xmlPotentials->functions->office->subfunctions->meals72->orderNotification->footer1);
foreach($mealOrder as $rowOrder)
{
sendMail($tempSubject,$tempBody,$rowOrder["meal_order_userid"]);
$mealOrderUpdate=$dbMaster->query(
"
UPDATE
fl_meal_order
SET meal_order_statusid = 6
WHERE
meal_order_id = ".$rowOrder["meal_order_id"]."
");
}
}
{
$localCSVPath ='D:\\Roger\\Events\\02_CSV\\01_Uploaded\\';
$localCSVPathProcessed='D:\\Roger\\Events\\02_CSV\\02_Processed\\';
$localCSVFiles =scandir($localCSVPath);
$localXMLPath ='D:\\Roger\\Events\\01_XML\\01_Uploaded\\';
$localXMLPathProcessed='D:\\Roger\\Events\\01_XML\\02_Processed\\';
$localXMLFiles =scandir($localXMLPath);
$tempErrors="";
foreach($localXMLFiles as $rowFile)
{
if(substr($rowFile,-3)=="xml") {
$xmlFile=simplexml_load_file($localXMLPath.$rowFile);
foreach($xmlFile->tables->table->rows->row as $row)
{
$fl_worktimeInsert=$dbMaster->prepare(
"
INSERT INTO fl_worktime
(
worktime_rogeruniqueid,
worktime_rogerid,
worktime_datetime,
worktime_code,
worktime_rogeruserid,
worktime_rogeruserguid,
worktime_readerid,
worktime_doortype,
worktime_modificationreason,
worktime_importdatetime,
worktime_importfilename
)
VALUES
(
'".$row->f[0]."',
'".$row->f[1]."',
'".$row->f[2]." ".$row->f[3]."',
'".$row->f[4]."',
'".$row->f[5]."',
'".$row->f[6]."',
'".$row->f[7]."',
'".$row->f[8]."',
'".$row->f[10]."',
'".date("Y-m-d H:i:s")."', '".$rowFile."'
)
");
if($fl_worktimeInsert->execute())
{
}
else
{
$tempErrors.=$rowFile.";".$row->f[0]."<br/>";
}
}
rename($localXMLPath.$rowFile,$localXMLPathProcessed.$rowFile); sendMail("Roger Processing",$tempErrors,10);
}
}
}
break;
default:
break;
}
?>