/**
 * This function sends a mail to the handler whenever the product reaches the reorder level.
 * Param $product_id - product id
 * Param $upd_qty - updated product quantity in no's
 * Param $prod_name - product name
 * Param $qtyinstk - quantity in stock
 * Param $qty - quantity
 * Param $module - module name
 * return type void
 */
function sendPrdStckMail($product_id, $upd_qty, $prod_name, $qtyinstk, $qty, $module)
{
    global $log;
    $log->debug("Entering sendPrdStckMail(" . $product_id . "," . $upd_qty . "," . $prod_name . "," . $qtyinstk . "," . $qty . "," . $module . ") method ...");
    global $current_user;
    global $adb;
    $reorderlevel = getPrdReOrderLevel($product_id);
    $log->debug("Inside sendPrdStckMail function, module=" . $module);
    $log->debug("Prd reorder level " . $reorderlevel);
    if ($upd_qty < $reorderlevel) {
        //send mail to the handler
        $handler = getRecordOwnerId($product_id);
        foreach ($handler as $type => $id) {
            $handler = $id;
        }
        $handler_name = getOwnerName($handler);
        if (vtws_isRecordOwnerUser($handler)) {
            $to_address = getUserEmail($handler);
        } else {
            $to_address = implode(',', getDefaultAssigneeEmailIds($handler));
        }
        //Get the email details from database;
        if ($module == 'SalesOrder') {
            $notification_table = 'SalesOrderNotification';
            $quan_name = '{SOQUANTITY}';
        }
        if ($module == 'Quotes') {
            $notification_table = 'QuoteNotification';
            $quan_name = '{QUOTEQUANTITY}';
        }
        if ($module == 'Invoice') {
            $notification_table = 'InvoiceNotification';
        }
        $query = "select * from vtiger_inventorynotification where notificationname=?";
        $result = $adb->pquery($query, array($notification_table));
        $subject = $adb->query_result($result, 0, 'notificationsubject');
        $body = $adb->query_result($result, 0, 'notificationbody');
        $status = $adb->query_result($result, 0, 'status');
        if ($status == 0 || $status == '') {
            return false;
        }
        $subject = str_replace('{PRODUCTNAME}', $prod_name, $subject);
        $body = str_replace('{HANDLER}', $handler_name, $body);
        $body = str_replace('{PRODUCTNAME}', $prod_name, $body);
        if ($module == 'Invoice') {
            $body = str_replace('{CURRENTSTOCK}', $upd_qty, $body);
            $body = str_replace('{REORDERLEVELVALUE}', $reorderlevel, $body);
        } else {
            $body = str_replace('{CURRENTSTOCK}', $qtyinstk, $body);
            $body = str_replace($quan_name, $qty, $body);
        }
        $body = str_replace('{CURRENTUSER}', $current_user->user_name, $body);
        $mail_status = send_mail($module, $to_address, $current_user->user_name, $current_user->email1, decode_html($subject), nl2br(to_html($body)));
    }
    $log->debug("Exiting sendPrdStckMail method ...");
}
Esempio n. 2
0
function vtws_getOwnerType($ownerId)
{
    if (vtws_isRecordOwnerGroup($ownerId) == true) {
        return 'Groups';
    }
    if (vtws_isRecordOwnerUser($ownerId) == true) {
        return 'Users';
    }
    throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Invalid owner of the record");
}
Esempio n. 3
0
function vtws_getOwnerType($ownerId)
{
    /** Б• 150824ГeГXГg СеМF  Б• ******/
    return 'Users';
    /** Б£ 150824ГeГXГg СеМF  Б£ ******/
    if (vtws_isRecordOwnerGroup($ownerId) == true) {
        return 'Groups';
    }
    if (vtws_isRecordOwnerUser($ownerId) == true) {
        return 'Users';
    }
    //Б°М†МјБ|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|Б|
    throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Invalid owner of the record");
}