<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header(     "Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With" );
require_once('f_send_email_notification.php');
require_once ('config.php');


 

$doc_no = NULL;



 
$wkr_mst_wr_no ='WR108782';
$orderId = 'WR108782';
$wkr_mst_wr_descs = 'WR108782WR108782WR108782WR108782WR108782WR108782WR108782WR108782';
$assetNoD = 'WR10WR108782';
$workD = 'WR108WR108782WR108782WR108782';
$levelD = 'WR108WR108782WR108782WR108782';
$url = '';

$eml_log_from='CMMS ADMIN';
 $eml_log_to_email = array();
 $eml_log_to_email[] = 'rsekhar9797@gmail.com';
 $audit_user    =  'ANDROID_LOG';
 $module   =     'Work Request';
 $action   =     'New WR';
 $trigger_from   =     NULL;
 $site_cd ='MSW';





$body = '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Work Request Disapproval</title>
    <style>
        /* Reset styles for better compatibility */
        body, table, td, a {
            -webkit-text-size-adjust: 100%;
            -ms-text-size-adjust: 100%;
        }
        table, td {
            mso-table-lspace: 0pt;
            mso-table-rspace: 0pt;
        }
        img {
            -ms-interpolation-mode: bicubic;
        }
        /* Style adjustments */
        body {
            margin: 0;
            padding: 0;
            width: 100%;
            background-color: #f4f7fa;
            font-family: Arial, sans-serif;
            color: #333;
        }
        .container {
            width: 100%;
            max-width: 600px;
            margin: 20px auto;
            background-color: #ffffff;
            border-radius: 8px;
            overflow: hidden;
        }
        .header, .footer {
            background-color: #d9534f;
            color: #ffffff;
            padding: 20px;
            text-align: center;
        }
        .header h1 {
            font-size: 24px;
            margin: 0;
        }
        .card {
            background-color: #ffffff;
            margin: 20px;
            padding: 20px;
            border: 1px solid #e3e3e3;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }
        .card h2 {
            font-size: 18px;
            color: #d9534f;
            margin: 0 0 10px;
        }
        .content p {
            font-size: 16px;
            margin: 0 0 10px;
        }
        .table {
            width: 100%;
            border-collapse: collapse;
            margin: 10px 0 0;
        }
        .table th, .table td {
            padding: 8px 12px;
            text-align: left;
            border: 1px solid #e3e3e3;
        }
        .table th {
            background-color: #fbe5e5;
            font-weight: bold;
            color: #d9534f;
        }
        .footer a {
            color: #ffffff;
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <table role="presentation" cellpadding="0" cellspacing="0" width="100%">
        <tr>
            <td align="center">
                <table class="container" width="100%" cellpadding="0" cellspacing="0">
                    <!-- Header Section -->
                    <tr>
                        <td class="header">
                            <h1>Work Request Disapproval</h1>
                            <p>We regret to inform you that your request has been disapproved.</p>
                        </td>
                    </tr>

                    <!-- Rejection Summary Card -->
                    <tr>
                        <td>
                            <div class="card">
                                <h2>Rejection Details</h2>
                                <p><strong>Rejected By:</strong> John Doe</p>
                                <p><strong>Reject Date:</strong> 2024-11-07</p>
                                <p><strong>Reject Reason:</strong> Double request complaint (not stock board call bell) awaiting stock from vendor nurse call</p>
                            </div>
                        </td>
                    </tr>

                    <!-- Work Request Details Card -->
                    <tr>
                        <td>
                            <div class="card">
                                <h2>Work Request Details</h2>
                                <table class="table">
                                    <tr>
                                        <th>WR Number</th>
                                        <td>WR108782</td>
                                    </tr>
                                    <tr>
                                        <th>Asset Number</th>
                                        <td>H01 (KPJ Damansara Specialist Hospital)</td>
                                    </tr>
                                    <tr>
                                        <th>Work Area</th>
                                        <td>CALL BALL 625 TAK ADM BUNYI</td>
                                    </tr>
                                    <tr>
                                        <th>Level</th>
                                        <td>L02 (Level 2)</td>
                                    </tr>
                                    <tr>
                                        <th>Asset Location</th>
                                        <td>-</td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>

                    <!-- Footer Section -->
                    <tr>
                        <td class="footer">
                            <p>If you need further assistance, please reach out to us at 
                               <a href="mailto:support@example.com">support@example.com</a>.
                            </p>
                            <p>&copy; 2024 Your Company Name</p>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>




';




	 $title  = 'CMMS Work Request Successfully Submitted : ' .$orderId. ' ';
	
	
	 
 
		 send_email($site_cd,$eml_log_from,$eml_log_to_email,$title,$body,$audit_user,$wkr_mst_wr_no,$module,$action,$trigger_from,NULL,NULL,NULL);
	 

returnData($orderId);	


function returnData($orderId){
	
	$returnData = array(
	'status' => 'SUCCESS',
	'ROW_ID'=>	$orderId,
	'message' => 'Work Order Number : ' .$orderId. ' created successfully');
	echo json_encode($returnData);
}

function returnError($error_message){	
	
	$returnData = array(
	'status' => 'ERROR',
	'message' => $error_message);	
	echo json_encode($returnData);
	exit();
}


 
?>