////	inform requesters about failure
        $emlTo = $arrRequesterData['email'];
        $Subject = "Khong tim duoc bai bao cua ban";
        $message = "<html>\n\t\t<head>\n\t\t<title>Yêu cầu thất bại</title>\n\t\t</head>\n\t\t<body>\n\t\tĐây là email tự động gửi từ ban quản trị của {$strWebsiteName}.<br/>\n\t\tChúng tôi không tìm được một trong những bài báo theo yêu cầu của bạn tại {$strWebsiteName} .<br />\n\t\tXin hãy đăng nhập vào trang web <a href=\"http://{$strWebsiteName}\">{$strWebsiteName} </a> để biết thêm chi tiết.\n\t\t</body>\n\t\t</html>";
        if (do_send($emlTo, $arrRequesterData['username'], $Subject, $message)) {
            echo "email to " . $arrRequesterData['username'] . ": SUCCESSFUL";
        } else {
            echo "email to " . $arrRequesterData['username'] . ": FAILED";
        }
    }
}
///////////////	Main	////////////////////
//Get current date
$today = date('Y-m-d');
//	Get all requests which are config.php/$GLOBALS['DisableSupplierThreshold'] days late
$strMysqlQuery = "SELECT `SupplierID` FROM " . $GLOBALS['strTableRequestName'] . " WHERE DATEDIFF('{$today}', `date_assigned`)>=" . $GLOBALS['DisableSupplierThreshold'];
$SelectLateRequestResult = mysql_query($strMysqlQuery) or die(mysql_error());
//	Get list of all late suppliers and disable them
while ($arrLateRequestData = mysql_fetch_array($SelectLateRequestResult)) {
    $arrLateSupplierID[] = $arrLateRequestData['SupplierID'];
    DisableSupplier($arrLateRequestData['SupplierID']);
}
//	Redistribute waiting papers
foreach ($arrLateSupplierID as $LateSupplierID) {
    $strMysqlQuery = "SELECT * FROM " . $GLOBALS['strTableRequestName'] . " WHERE (`SupplierID`= {$LateSupplierID}) AND (status>-1)";
    $SelectRequestResult = mysql_query($strMysqlQuery) or die(mysql_error());
    //	Get list of request for current LateSupplier
    while ($arrRequestData = mysql_fetch_array($SelectRequestResult)) {
        PassRequest($arrRequestData);
    }
}
Exemple #2
0
     } else {
         $strMysqlQuery = "UPDATE {$strTableRequestName} SET status = -2 WHERE id=" . $arrRequestData['id'];
         mysql_query($strMysqlQuery) or die(mysql_error());
     }
 }
 ///////////////	Main	////////////////////
 //Get current date
 $today = date('Y-m-d');
 //	Get all requests which are config.php/$GLOBALS['DisableSupplierThreshold'] days late
 $strMysqlQuery = "SELECT * FROM " . $GLOBALS['strTableRequestName'] . " WHERE DATEDIFF('{$today}', `date_assigned`)>=" . $GLOBALS['DisableSupplierThreshold'] . " GROUP BY `supplier`";
 $SelectLateRequestResult = mysql_query($strMysqlQuery) or die(mysql_error());
 //	Get list of all late suppliers and disable them
 if (mysql_num_rows($SelectLateRequestResult) > 0) {
     while ($arrLateRequestData = mysql_fetch_array($SelectLateRequestResult)) {
         $arrLateSuppliers[] = $arrLateRequestData['supplier'];
         DisableSupplier($arrLateRequestData['supplier']);
     }
     //	Redistribute waiting papers
     foreach ($arrLateSuppliers as $LateSupplier) {
         $strMysqlQuery = "SELECT * FROM " . $GLOBALS['strTableRequestName'] . " WHERE (`supplier`= '{$LateSupplier}') AND (status>-1)";
         $SelectRequestResult = mysql_query($strMysqlQuery) or die(mysql_error());
         //	Get list of requests for current LateSupplier
         while ($arrRequestData = mysql_fetch_array($SelectRequestResult)) {
             echo "<br />______________<br />Passing Request " . $arrRequestData['id'] . "<br />";
             PassRequest($arrRequestData);
         }
     }
 } else {
     echo "Khong co yeu cau muon " . $GLOBALS['DisableSupplierThreshold'] . " ngay.<br />\r\n";
 }
 //	Remind suppliers with requests $GLOBALS['WarnSupplierThreshold'] days late