components_node/functions-email.js
/**
     * Function build content based on system form.
     * @static
     * @param {int} _idTbForms 
     * @param {object} _objPostData 
     * @param {int} _emailFormat 
     * @returns {object}
     * @example
     * SyncSystemNS.FunctionsEmail.emailSend({})
     */
Function build content based on system form.
Function build content based on system form .
static async formsContent(_idTbForms, _objPostData, _emailFormat = 0)
    {
        let objReturn = {returnStatus: false}; 
        let formsContentText = "";
        let formsContentHTML = "";
        let idTbForms; 
        let objPostData; 
        let emailFormat;
        let offlRecordsParameters;
        let offlRecords;
        idTbForms = _idTbForms;
        objPostData = _objPostData;
        emailFormat = _emailFormat;
            try{ 
                offlRecordsParameters = {
                    _arrSearchParameters: ["id_forms;" + idTbForms + ";i"],
                    _configSortOrder: gSystemConfig.configFormsFieldsSort,
                    _strNRecords: "",
                    _objSpecialParameters: {returnType: 3}
                };
                offlRecords = new ObjectFormsFieldsListing(offlRecordsParameters);
                await offlRecords.recordsListingGet(0, 3);
                offlRecords.resultsFormsFieldsListing.forEach((formsFieldsRow)=>{
                    if(gSystemConfig.configUploadComponent == 1)
                    {
                        if(formsFieldsRow.field_type == 1 
                            || formsFieldsRow.field_type == 2
                            || formsFieldsRow.field_type == 4
                            || formsFieldsRow.field_type == 5)
                        {
                            formsContentText += FunctionsGeneric.contentMaskRead(formsFieldsRow.field_name, "db") + " ";
                            if(objPostData._fields[formsFieldsRow.field_name_formatted])
                            {
                                formsContentText += objPostData._fields[formsFieldsRow.field_name_formatted];
                            }
                            formsContentText += "\n";
                            formsContentHTML += FunctionsGeneric.contentMaskRead(formsFieldsRow.field_name, "db") + " ";
                            if(objPostData._fields[formsFieldsRow.field_name_formatted])
                            {
                                formsContentHTML += objPostData._fields[formsFieldsRow.field_name_formatted];
                            }
                            formsContentHTML += "<br />";
                        }
                        if(formsFieldsRow.field_type == 3)
                        {
                            if(objPostData._fieldsMultipleValues.hasOwnProperty(formsFieldsRow.field_name_formatted + "[]") === true)
                            {
                                formsContentText += FunctionsGeneric.contentMaskRead(formsFieldsRow.field_name, "db") + " ";
                                formsContentText += objPostData._fieldsMultipleValues[formsFieldsRow.field_name_formatted + "[]"].join(", ");
                                formsContentText += "\n";
                                formsContentHTML += FunctionsGeneric.contentMaskRead(formsFieldsRow.field_name, "db") + " ";
                                formsContentHTML += objPostData._fieldsMultipleValues[formsFieldsRow.field_name_formatted + "[]"].join(", ");
                                formsContentHTML += "<br />";
                            }
                        }
                        if(formsFieldsRow.field_type == 7 
                            || formsFieldsRow.field_type == 8)
                        {
                            formsContentText += FunctionsGeneric.contentMaskRead(formsFieldsRow.field_name, "db");
                            formsContentText += "\n";
                            formsContentHTML += FunctionsGeneric.contentMaskRead(formsFieldsRow.field_name, "db");
                            formsContentHTML += "<br />";
                        }
                    }
                });
                objReturn.returnStatus = true;
                objReturn.formsContentHTML = formsContentHTML;
                objReturn.formsContentText = formsContentText;
            }catch(formsContentError){
                if(gSystemConfig.configDebug === true)
                {
                    console.log("formsContentError=", formsContentError);
                    console.error("formsContentError=", formsContentError);
                }
            }finally{
                return objReturn;
            }
    }
static async formsContent ( _idTbForms , _objPostData , _emailFormat = 0 ) { let objReturn = { returnStatus : false } ; let formsContentText = "" ; let formsContentHTML = "" ; let idTbForms ; let objPostData ; let emailFormat ; let offlRecordsParameters ; let offlRecords ; idTbForms = _idTbForms ; objPostData = _objPostData ; emailFormat = _emailFormat ; try { offlRecordsParameters = { _arrSearchParameters : [ "id_forms;" + idTbForms + ";i" ] , _configSortOrder : gSystemConfig . configFormsFieldsSort , _strNRecords : "" , _objSpecialParameters : { returnType : 3 } } ; offlRecords = new ObjectFormsFieldsListing ( offlRecordsParameters ) ; await offlRecords . recordsListingGet ( 0 , 3 ) ; offlRecords . resultsFormsFieldsListing . forEach ( ( formsFieldsRow ) => { if ( gSystemConfig . configUploadComponent == 1 ) { if ( formsFieldsRow . field_type == 1 || formsFieldsRow . field_type == 2 || formsFieldsRow . field_type == 4 || formsFieldsRow . field_type == 5 ) { formsContentText += FunctionsGeneric . contentMaskRead ( formsFieldsRow . field_name , "db" ) + " " ; if ( objPostData . _fields [ formsFieldsRow . field_name_formatted ] ) { formsContentText += objPostData . _fields [ formsFieldsRow . field_name_formatted ] ; } formsContentText += "\n" ; formsContentHTML += FunctionsGeneric . contentMaskRead ( formsFieldsRow . field_name , "db" ) + " " ; if ( objPostData . _fields [ formsFieldsRow . field_name_formatted ] ) { formsContentHTML += objPostData . _fields [ formsFieldsRow . field_name_formatted ] ; } formsContentHTML += "<br />" ; } if ( formsFieldsRow . field_type == 3 ) { if ( objPostData . _fieldsMultipleValues . hasOwnProperty ( formsFieldsRow . field_name_formatted + "[]" ) === true ) { formsContentText += FunctionsGeneric . contentMaskRead ( formsFieldsRow . field_name , "db" ) + " " ; formsContentText += objPostData . _fieldsMultipleValues [ formsFieldsRow . field_name_formatted + "[]" ] . join ( ", " ) ; formsContentText += "\n" ; formsContentHTML += FunctionsGeneric . contentMaskRead ( formsFieldsRow . field_name , "db" ) + " " ; formsContentHTML += objPostData . _fieldsMultipleValues [ formsFieldsRow . field_name_formatted + "[]" ] . join ( ", " ) ; formsContentHTML += "<br />" ; } } if ( formsFieldsRow . field_type == 7 || formsFieldsRow . field_type == 8 ) { formsContentText += FunctionsGeneric . contentMaskRead ( formsFieldsRow . field_name , "db" ) ; formsContentText += "\n" ; formsContentHTML += FunctionsGeneric . contentMaskRead ( formsFieldsRow . field_name , "db" ) ; formsContentHTML += "<br />" ; } } } ) ; objReturn . returnStatus = true ; objReturn . formsContentHTML = formsContentHTML ; objReturn . formsContentText = formsContentText ; } catch ( formsContentError ) { if ( gSystemConfig . configDebug === true ) { console . log ( "formsContentError=" , formsContentError ) ; console . error ( "formsContentError=" , formsContentError ) ; } } finally { return objReturn ; } }
Function build content based on system form.
Function build content based on system form .
/*
        _emailFormat: 1 //0 - text | 1 - HTML
        _objPostData: {
            _fields: {},
            _fieldsMultipleValues: {}, //For checkbox and listbox
            _files: {}
        }
        */ //Variables. //---------------------- //objReturn: {returnStatus: false, formsContentText: "", formsContentHTML: ""} //let ofdRecordParameters; //let ofdRecord; //---------------------- //Define values. //---------------------- //---------------------- //Logic. //---------------------- //(async function(){ //async marks the block //Forms detail. /*
                ofdRecordParameters = {
                    _arrSearchParameters: ["id;" + idTbForms + ";i"],
                    _idTbForms: idTbForms,
                    _terminal: 0,
                    _objSpecialParameters: {returnType: 3}
                }

                ofdRecord = new ObjectFormsDetails(ofdRecordParameters);
                await ofdRecord.recordDetailsGet(0, 3);
                */ //Forms fields. //Loop through forms fields records. //formidable //Text Field | Text Area | Radio Box | Dropdown Menu //Build content - text. //Build content - HTML. //Check Box //Build content - text. //Build content - HTML. //Debug. //console.log("objPostData._fieldsMultipleValues[formsFieldsRow.field_name_formatted (inside function - checkbox)=", formsFieldsRow.field_name_formatted + "[]"); //Text Description | Subheader //Build content - HTML. //Build content - HTML. //formsContentHTML += objPostData._fields[formsFieldsRow.field_name_formatted]; //Debug. //console.log("formsFieldsRow.field_name_formatted (inside function)=", formsFieldsRow.field_name_formatted); //console.log("formsFieldsRow.field_name_formatted (inside function)=", formsFieldsRow.field_name_formatted); //Build object return. //Debug. //console.log("idTbForms (inside function)=", idTbForms); //console.log("objPostData (inside function)=", objPostData); //console.log("emailFormat (inside function)=", emailFormat); //console.log("ofdRecord (inside function)=", ofdRecord); //console.log("offlRecords (inside function)=", offlRecords); //})() //----------------------