{"pc":{"type":"Grid","model":{"stacked":"md","rows":[{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"Text","model":{"_internalName":"Text1","text":"<h1>Sales Quote form</h1>"}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"Text","model":{"_internalName":"Text4","text":"<span style=\"color:#373a3c;background-color:#ffffff;\">Fill in and submit this form to issue a sales quote.</span>"}}}]},{"cells":[{"offset":0,"width":6,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"Date","model":{"_internalName":"issued","required":true,"orientation":"Vertical","text":"Issued on","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal"}}},{"offset":0,"width":6,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"Date","model":{"_internalName":"valid","required":true,"orientation":"Vertical","text":"Valid until","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal"}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"Number","required":true,"orientation":"Vertical","type":"Anything","text":"Quote number","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal"}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"Text","model":{"_internalName":"Text2","text":"<h3>Vendor details</h3>"}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"vendorName","required":true,"orientation":"Vertical","type":"Anything","text":"Vendor company name","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal"}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"vendorAddress","required":true,"orientation":"Vertical","type":"Anything","text":"Vendor address","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal"}}}]},{"cells":[{"offset":0,"width":6,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"vendorEmail","required":true,"orientation":"Vertical","type":"E-mail","text":"Vendor email","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cHint":"username@domain.com","cFontStyle":"Normal","cFontWeight":"Normal","pattern":"^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$","error":"This field must contain a valid e-mail address."}}},{"offset":0,"width":6,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"vendorPhone","required":true,"orientation":"Vertical","type":"Phone","text":"Vendor phone","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cHint":"123-456-7890","cFontStyle":"Normal","cFontWeight":"Normal","pattern":"^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]\\d{3}[\\s.-]\\d{4}$","error":"This field must contain a valid phone number."}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"Text","model":{"_internalName":"Text3","text":"<h3>Customer details</h3>"}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"customerName","required":true,"orientation":"Vertical","type":"Anything","text":"Customer company name","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal"}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"customerAddress","required":true,"orientation":"Vertical","type":"Anything","text":"Customer address","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal"}}}]},{"cells":[{"offset":0,"width":6,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"customerEmail","required":true,"orientation":"Vertical","type":"Anything","text":"Customer email","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal"}}},{"offset":0,"width":6,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"customerPhone","required":true,"orientation":"Vertical","type":"Anything","text":"Customer phone","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal","cHint":"123-456-7890"}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"Text","model":{"_internalName":"Text5","text":"<h3>Description</h3>"}}}]},{"cells":[{"offset":0,"width":12,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"DataTable","model":{"columns":[{"_internalName":"name","title":"Products","required":true,"type":"String"},{"_internalName":"quantity","title":"Quantity","required":true,"type":"Number","decimals":0,"format":"n0","step":1},{"_internalName":"price","title":"Unit Price","required":true,"type":"Number","decimals":0,"format":"n0","step":1},{"_internalName":"cost","title":"Total cost","required":true,"type":"Number","decimals":0,"format":"n0","step":1}],"_internalName":"products","newLine":"Bottom","delete":"Last"}}}]},{"cells":[{"offset":8,"width":4,"padding":[null,null,null,null],"alignment":"Justify","component":{"type":"SingleLineText","model":{"_internalName":"OrderTotal","required":true,"orientation":"Horizontal","type":"Anything","text":"Total ($)","visible":true,"fontStyle":"Normal","fontWeight":"Normal","wrap":true,"cFontStyle":"Normal","cFontWeight":"Normal"}}}]},{"cells":[{"offset":0,"width":6,"padding":[null,null,null,null],"alignment":"Left","component":{"type":"Submit","model":{"_internalName":"Submit1","text":"Create sales quote","type":"Primary","click":"return fd.save();"}}}]}]}},"phone":null,"tablet":null,"js":"//once the form is rendered\r\nfd.rendered(function() {\r\n    //Disable Order Total field\r\n    fd.field('OrderTotal').disabled = true;\r\n    //Make Total column noneditable\r\n    fd.control('products').columns[3].editable =\r\n        function(){return false};\r\n    fd.control('products').$on('change', function(value) {\r\n        //variable to count Order Total\r\n        var orderTotal = 0;\r\n        //if there are records in the table\r\n        var isTableModified = false;\r\n        if(value){\r\n            //go through each one by one\r\n            for (var i = 0; i < value.length; i++){\r\n                //if this record has Amount and Price\r\n                if(value[i].quantity && value[i].price){\r\n                    //set Total to their product\r\n                    var cost = value[i].quantity * value[i].price;\r\n                    if (value[i].cost != cost) {\r\n                        value[i].cost = cost;\r\n                        isTableModified = true;\r\n                    }\r\n                //add Total to the Order Total\r\n                orderTotal += parseInt(value[i].cost);\r\n                }\r\n            }\r\n        }\r\n        //here we make our change to the table\r\n        if (isTableModified) {\r\n            fd.control('products').value = value;\r\n        }\r\n        //we set Order Total field to sum of Totals\r\n        fd.field('OrderTotal').value = orderTotal;\r\n    });\r\n});\r\n\r\n/*****************************************************************************\r\nThe JavaScript code from this section will be executed while loading\r\nthe current form.\r\n\r\nThe following predefined variables can be utilized in the code:\r\n\r\nfd  - instance of the current form\r\n$   - jQuery object\r\n\r\n==============================================================================\r\n\r\nfd.rendered(function () {\r\n    // This code is executed once the form is rendered\r\n\r\n    // Hide State field for all values of Country field except 'USA'\r\n    function updateStateVisibility() {\r\n        var stateContainer = $(fd.field('State').$el).closest('.form-group');\r\n        if (fd.field('Country').value === 'USA') {\r\n            stateContainer.show();\r\n        } else {\r\n            stateContainer.hide();\r\n        }\r\n    }\r\n\r\n    // Set initial State visibility\r\n    updateStateVisibility();\r\n\r\n    // Update State visibility after changing Country\r\n    fd.field('Country').$on('change', updateStateVisibility)\r\n});\r\n\r\nfd.beforeSave(function () {\r\n    // This code is exeuted before saving the form and\r\n    // may return Promise. The saving does not proceed until\r\n    // the Promise is resolved. If the Promise is rejected,\r\n    // the saving interrupts. This is the appropriate place\r\n    // for adding custom validation.\r\n\r\n    // Prevent saving if Start Date is greater than End Date\r\n    if (fd.field('StartDate').value > fd.field('EndDate').value) {\r\n        throw Error('Start Date must not be greater than End Date.');\r\n    }\r\n});\r\n\r\nfd.saved(function (result) {\r\n    // This code is executed after saving the form\r\n\r\n    // Forwarding users to specific URL\r\n    window.location = '--- Some URL ---';\r\n});\r\n\r\n*****************************************************************************/\r\n","css":null,"theme":null,"timezone":"Europe/Moscow","culture":"en-US","notifySubscribers":true}