using Plan2D; using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using Unity.Mathematics; using Unity.VisualScripting; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; using System.Text; using UnityEngine.Rendering; using Unity.Collections; using System.IO; using System.Drawing; //using System.Numerics; public class PDFCreation : MonoBehaviour { protected bool _isHD = false; public Text _output; public int _copies = 1; public GameObject _myPanel; protected Plan2DHandler _handler; protected Byte[] _bytes; protected Byte[] _bytesP2D; protected Byte[] _islandBYTES; protected Byte[][] BYTES = new Byte[24][]; protected Byte[][] BYTESDoors = new Byte[4][]; protected Byte[][] BYTEScabTextures = new Byte[4][]; protected Byte[][] BYTESKnobs = new Byte[2][]; protected Byte[][] BYTESCounter = new Byte[1][]; protected bool _isCiecommerce; protected List FORMCABS = new List(); protected int _objCount; private int _textureWidth = 256; private int _textureHeight = 256; private Vector3 _originalCameraPosition; private Quaternion _originalCameraRotation; private RenderTexture _renderTexture; //private RenderTexture _renderTexturePlan2D; //private RenderTexture _renderTextureElevation; //private string Category; private int ElevationIndex; private int NumberOfElevation=0; private int ElevationDone=0; protected void Initialize(out Camera mainCam) { _objCount=0; _isHD = _G.HD; _bytes = null; //if (_G.status == "JN") Save_WEB.Save_WebJN(); PAINT.SEL = ""; SceneModeManager.Instance.SetSceneMode(SceneModes.Panel);//"PNL"; transform.GetChild(0).gameObject.SetActive(false); GameObject.Find("Panel_SCENE").GetComponent().alpha = 0; BYTES = new Byte[24][]; //GameObject.Find("HIDER").transform.Find("LoadingCircle").gameObject.SetActive(true); //WaitCircle.Setting(true, TRANS.This("M_PDFCONSTRUCT") ); print("------------------------------PDFGO plan----------------------"); GameObject.Find("Panel_SCENE").GetComponent().alpha = 1; mainCam = Camera.main; _originalCameraPosition = mainCam.transform.position; _originalCameraRotation = mainCam.transform.rotation; _handler = Plan2DHandler.Instance; if (_bytes?.Length > 0 ){print("--------------------------Not empty--------------------1-----------------");} else {print("------------------------------------------------Ok it is empty------------------------1--------------");} } //----SCREEN SHOTS--------------------------------------------------------------------------------------------------------SCREEN SHOTS //----SCREEN SHOTS--------------------------------------------------------------------------------------------------------SCREEN SHOTS //----SCREEN SHOTS--------------------------------------------------------------------------------------------------------SCREEN SHOTS // protected Texture2D RTImage() // { // int width = Screen.width; // int height = Screen.height; // Texture2D _screenShot = new Texture2D(width, height, TextureFormat.RGB24, false); // _screenShot.ReadPixels(new Rect(0, 0, width, height), 0, 0, false); // _screenShot.Apply(); // return _screenShot; // } // protected Texture2D RTImageV2(Camera camera) // { // //DASH.HDsetBTNcolor(false); // RenderTexture rt = new (2560, 1500, 32, RenderTextureFormat.ARGB32); // camera.targetTexture = rt; // RenderTexture.active = rt; // camera.Render(); // Texture2D _screenShot = new (2560, 1500, TextureFormat.RGB24, false); // _screenShot.ReadPixels(new Rect(0, 0, 2560, 1500), 0, 0); // _screenShot.Apply(); // camera.targetTexture = null; // RenderTexture.active = null; // camera.targetTexture = null; // Destroy(rt); // return _screenShot; // } // protected Texture2D RTImageV3() // { // int width = Screen.width; // int height = Screen.height; // Texture2D _screenShot = new Texture2D(width, height, TextureFormat.RGB24, false); // _screenShot.ReadPixels(new Rect(0, 0, width, height), 0, 0, false); // _screenShot.Apply(); // return _screenShot; // } //Scene protected IEnumerator TakeScreenshotScene() { //Set camera _handler.Close2DPlan(); DASH.HDsetBTNcolor(true); ReturnCameraToInitialPosition(); SetSceneViewUpFront(false); // //Render //yield return new WaitForEndOfFrame(); yield return new WaitForSeconds(0.5f); _renderTexture = new RenderTexture(Screen.width, Screen.height, 0); ScreenCapture.CaptureScreenshotIntoRenderTexture(_renderTexture); AsyncGPUReadback.Request(_renderTexture, 0, TextureFormat.RGBA32, ReadbackCompletedScene); } void ReadbackCompletedScene(AsyncGPUReadbackRequest request) { var format = _renderTexture.graphicsFormat; uint Uwidth = (uint)_renderTexture.width; uint Uheight = (uint)_renderTexture.height; _renderTexture.Release(); var processedData = RequestFlip(request); _bytes = ImageConversion.EncodeArrayToPNG(processedData.ToArray(), format, Uwidth, Uheight); SetSceneViewUpFront(true); DASH.HDsetBTNcolor(false); NextScreenshot("Plan2D"); } //Plan2D protected IEnumerator TakeScreenshotPlan2D() { //Set camera _handler.Start2DPlan(); _handler.SetPlan2DButtonOverlayActive(false); Get.o2("PLAN2DHandler/CanvasPlan","BTNS").SetActive(false); //Render //yield return new WaitForEndOfFrame(); yield return new WaitForSeconds(0.5f); _renderTexture = new RenderTexture(Screen.width, Screen.height, 0); ScreenCapture.CaptureScreenshotIntoRenderTexture(_renderTexture); AsyncGPUReadback.Request(_renderTexture, 0, TextureFormat.RGBA32, ReadbackCompletedPlan2D); } void ReadbackCompletedPlan2D(AsyncGPUReadbackRequest request) { // Render texture no longer needed, it has been read back. var format = _renderTexture.graphicsFormat; uint Uwidth = (uint)_renderTexture.width; uint Uheight = (uint)_renderTexture.height; _renderTexture.Release(); var processedData = RequestFlip(request); _bytesP2D = ImageConversion.EncodeArrayToPNG(processedData.ToArray(), format, Uwidth, Uheight); ElevationDone=0; NextScreenshot("Elevation"); } //Elevation protected IEnumerator TakeScreenshotElevation() { _handler.SetPlan2DButtonOverlayActive(false); //Render //yield return new WaitForEndOfFrame(); yield return new WaitForSeconds(0.5f); _renderTexture= new RenderTexture(Screen.width, Screen.height, 0); ScreenCapture.CaptureScreenshotIntoRenderTexture(_renderTexture); AsyncGPUReadback.Request(_renderTexture, 0, TextureFormat.RGBA32, ReadbackCompletedElevation); } void ReadbackCompletedElevation(AsyncGPUReadbackRequest request) { var format = _renderTexture.graphicsFormat; uint Uwidth = (uint) _renderTexture.width; uint Uheight = (uint) _renderTexture.height; _renderTexture.Release(); var processedData = RequestFlip(request); BYTES[ElevationIndex] = ImageConversion.EncodeArrayToPNG(processedData.ToArray(), format, Uwidth, Uheight); //_handler.SetPlan2DButtonOverlayActive(true); ElevationDone+=1; NextScreenshot("Elevation"); //Invoke(nameof(NextElevation), 1.0f); } void NextElevation(){ NextScreenshot("Elevation"); } //Island protected IEnumerator TakeScreenshotIsland() { //_handler.ShowIslandCut(); yield return new WaitForSeconds(0.5f); //Get.o2("PLAN2DHandler/CanvasPlan","BTNS").SetActive(false); //Render //yield return new WaitForEndOfFrame(); _renderTexture= new RenderTexture(Screen.width, Screen.height, 0); ScreenCapture.CaptureScreenshotIntoRenderTexture(_renderTexture); AsyncGPUReadback.Request(_renderTexture, 0, TextureFormat.RGBA32, ReadbackCompletedIsland); } void ReadbackCompletedIsland(AsyncGPUReadbackRequest request) { var format = _renderTexture.graphicsFormat; uint Uwidth = (uint) _renderTexture.width; uint Uheight = (uint) _renderTexture.height; _renderTexture.Release(); var processedData = RequestFlip(request); _islandBYTES = ImageConversion.EncodeArrayToPNG(processedData.ToArray(), format, Uwidth, Uheight); //Get.o2("PLAN2DHandler/CanvasPlan","BTNS").SetActive(true); NextScreenshot("Calculate"); } NativeArray RequestFlip(AsyncGPUReadbackRequest request){ var rawData = request.GetData(); var width = Screen.width; var height = Screen.height; var texture = new Texture2D(width, height, TextureFormat.RGBA32, false); var processedData = texture.GetRawTextureData(); for (int i = 0; i < rawData.Length; i += 4) { var arrayIndex = i / 4; var x = arrayIndex % width; var y = arrayIndex / width; var flippedY = (height - 1 - y); var flippedIndex = x + flippedY * width; // flip the data processedData[i] = rawData[flippedIndex * 4]; processedData[i + 1] = rawData[flippedIndex * 4 + 1]; processedData[i + 2] = rawData[flippedIndex * 4 + 2]; processedData[i + 3] = rawData[flippedIndex * 4 + 3]; } return processedData; } void NextScreenshot(string Next){ WaitCircle.Setting(false, "" ); if (Next == "Plan2D") StaticCoroutine.Start(TakeScreenshotPlan2D()); else if (Next == "Elevation") StaticCoroutine.Start(TakeElevationPictures()); else if (Next == "Island") StaticCoroutine.Start(TakeIslandScreenshot()); else if (Next == "Calculate") StaticCoroutine.Start(Calculate()); } protected IEnumerator TakeElevationPictures() { WaitCircle.Setting(false, "" ); print("ElevationDone===="+ElevationDone); _handler.Start2DPlan(); yield return new WaitForSeconds(0.5f); if(ElevationDone==0) { Transform Container=Get.o2("PLAN2DHandler","WorldButtonCanvas").transform; NumberOfElevation=Container.childCount; print("NumberOfElevation==="+NumberOfElevation); foreach(Transform btn in Container.transform){ print("btn name===="+btn.name ); } } if(ElevationDone().onClick.Invoke(); Get.o2("PLAN2DHandler/CanvasPlan","BTNS").SetActive(false); CAPS.SHOW_TOP(false,1); CAPS.SHOW_FRONT(true,0.7f); yield return TakeScreenshotElevation(); } else{ //buttons.Clear(); NextScreenshot("Island"); //Invoke(nameof(NextIsland), 2.0f); //yield return new WaitForSeconds(2f); //NextScreenshot("Island"); } // if(ElevationDone(); // Set the camera to orthographic mode. captureCamera.orthographic = true; // Clear the camera's color and depth buffers before rendering. captureCamera.clearFlags = CameraClearFlags.Color | CameraClearFlags.Depth; // Store the camera's original parameters. Vector3 originalPosition = captureCamera.transform.position; Rect originalViewportRect = captureCamera.rect; // Calculate the bounds of the mesh. MeshFilter meshFilter = meshObject.GetComponent(); Mesh mesh = meshFilter.mesh; Bounds meshBounds = mesh.bounds; // Calculate the camera's size to fit the mesh. float meshSize = Mathf.Max(meshBounds.extents.x, meshBounds.extents.y) * 2f; // Set the camera's orthographic size to fit the mesh. captureCamera.orthographicSize = meshSize * 0.5f; // Position the camera to focus on the center of the mesh. captureCamera.transform.position = meshBounds.center - captureCamera.transform.forward * 10f; // Adjust the Z position as needed. // Set the camera to only see objects on the "PDFPreview" layer. captureCamera.cullingMask = 1 << LayerMask.NameToLayer("PDFPreview"); // Create a RenderTexture with higher resolution to render the mesh onto. RenderTexture renderTexture = new RenderTexture(textureWidth, textureHeight, 0, RenderTextureFormat.ARGB32); renderTexture.filterMode = FilterMode.Bilinear; // Set the RenderTexture as the target for the capture camera. captureCamera.targetTexture = renderTexture; yield return new WaitForEndOfFrame(); // Render the camera to capture the mesh content. captureCamera.Render(); // Read the RenderTexture into a Texture2D. RenderTexture.active = renderTexture; Texture2D texture = new Texture2D(textureWidth, textureHeight); texture.ReadPixels(new Rect(0, 0, textureWidth, textureHeight), 0, 0); texture.Apply(); switch (Cat) { case "Door": BYTESDoors[idx] = texture.EncodeToPNG(); break; case "Counter": BYTESCounter[idx] = texture.EncodeToPNG(); break; case "CabTexture":BYTEScabTextures[idx] = texture.EncodeToPNG(); break; } // Clean up the RenderTexture and capture camera. RenderTexture.active = null; captureCamera.targetTexture = null; Destroy(renderTexture); Destroy(cameraGO); meshObject.SetActive(false); Destroy(meshObject); yield return new WaitForEndOfFrame(); } private Mesh CreateQuadMesh() { Mesh mesh = new Mesh(); Vector3[] vertices = new Vector3[4]; Vector2[] uv = new Vector2[4]; int[] triangles = new int[6]; // Define vertices and UVs for a quad vertices[0] = new Vector3(-0.5f, -0.5f, 0); vertices[1] = new Vector3(0.5f, -0.5f, 0); vertices[2] = new Vector3(-0.5f, 0.5f, 0); vertices[3] = new Vector3(0.5f, 0.5f, 0); uv[0] = new Vector2(0, 0); uv[1] = new Vector2(1, 0); uv[2] = new Vector2(0, 1); uv[3] = new Vector2(1, 1); // Define triangles triangles[0] = 0; triangles[1] = 2; triangles[2] = 1; triangles[3] = 2; triangles[4] = 3; triangles[5] = 1; mesh.vertices = vertices; mesh.uv = uv; mesh.triangles = triangles; return mesh; } private GameObject CreateMeshObject() { GameObject meshObject = new("MeshObject"); // Set up the mesh renderer and mesh filter components MeshRenderer meshRenderer = meshObject.AddComponent(); MeshFilter meshFilter = meshObject.AddComponent(); // Add a mesh (you may need to set up the mesh data appropriately) Mesh mesh = new Mesh(); // Set up the mesh data here meshFilter.mesh = mesh; return meshObject; } public IEnumerator Calculate() { //GameObject.Find("HIDER").transform.Find("LoadingCircle").gameObject.SetActive(false); WaitCircle.Setting(false, "" ); yield return null; //yield return new WaitForSeconds(2f); _handler.Close2DPlan(); DASH.HDsetBTNcolor(false); _handler.SetPlan2DButtonOverlayActive(true); AddFieldToPDF( out WWWForm form); //CompleteFormInfo1To5(form); //Calculate price and add to form List Cablist=DOLIST.CABLISTint(); AddFieldForCab( Cablist,form); if(Get.PreferenceBool("CABINET_DOOR_RECIPE")){ AddFieldForDoor(form);} AddFieldForPnl( form); //MOLDINGS AddFieldForMolding( "FILLER",Cablist,form); if(_P.ListSwitch["VALANCE_SELECT"]) AddFieldForMolding( "VALANCE",Cablist,form); if(_P.ListSwitch["FASCIA_SELECT"]) AddFieldForMolding( "FASCIA",Cablist,form); if(_P.ListSwitch["OGEE_SELECT"]) AddFieldForMolding( "OGEE",Cablist,form); AddFieldForMolding( "KICK",Cablist,form); //AddFieldForFiller( form); // if(_P.ListSwitch["VALANCE_SELECT"]) {AddFieldForValance( form);} // if(_P.ListSwitch["FASCIA_SELECT"]) {AddFieldForFascia( form);} // if(_P.ListSwitch["OGEE_SELECT"]) {AddFieldForOgee( form);} // AddFieldForKick( form); if(_P.ListSwitch["ADD_ITEM_LIST"]){AddFieldForItems( form);} //AddFieldForRecover(number, form); //AddFieldForKnob(number, form); int iteration = AddFieldElevation(form); //yield return new WaitForSeconds(2f); AddFieldForAllPictures(form); AddFieldForIsland(form, iteration); //yield return new WaitForEndOfFrame(); //_handler.SetPlan2DButtonOverlayActive(true); //_handler.Close2DPlan(); //yield return new WaitForSeconds(1f); StaticCoroutine.Start(SaveToServerCoroutine(form, ThisOnly.getUrlPDF())); //Get.o2("PLAN2DHandler/CanvasPlan","BTNS").SetActive(false); yield break; } //Open File input // public IEnumerator SaveToServerCoroutine(WWWForm form, string url) // { // //_handler.Close2DPlan(); // OpenInputField(); // ReturnCameraToInitialPosition(); // print("--------Save To Server-------------- " + url); // //GameObject.Find("HIDER").transform.Find("LoadingCircle").gameObject.SetActive(true); // WaitCircle.Setting(true, TRANS.This("M_PDFCONSTRUCT") ); // yield return null; // if (form != null) { Debug.Log("Form==" + form.data.Length); } // using UnityWebRequest webRequest = UnityWebRequest.Post(url, form); // yield return webRequest.SendWebRequest(); // if (webRequest.result != UnityWebRequest.Result.Success) // { // print("url===" + url); // print("Getting error " + webRequest.error);//url===https://ukitchenit.ca/fpdf/pdfset.php?0.1068056 // } // else // { // //print("--------data for _G.PDF-------------- " + webRequest.downloadHandler.data != null ? webRequest.downloadHandler.text : "null"); // //--------Save To Server-------------- https://ukitchenit.com/fpdf/pdfset.php?0.8361366 // _G.PDF = webRequest.downloadHandler.data; // // _handler.Close2DPlan(); // // OpenInputField(); // //GameObject.Find("HIDER").transform.Find("LoadingCircle").gameObject.SetActive(false); // WaitCircle.Setting(false, ""); // } // } public IEnumerator SaveToServerCoroutine(WWWForm form, string url) { OpenInputField(); ReturnCameraToInitialPosition(); Debug.Log("--------Save To Server-------------- " + url); WaitCircle.Setting(true, TRANS.This("M_PDFCONSTRUCT")); yield return null; if (form != null) { Debug.Log("Form length: " + form.data.Length); } using UnityWebRequest webRequest = UnityWebRequest.Post(url, form); // ❌ Ne jamais redéfinir Content-Type ici ! // ✅ En revanche, tu peux ajouter Origin si nécessaire : webRequest.SetRequestHeader("Origin", "https://ukitchenit.com"); yield return webRequest.SendWebRequest(); if (webRequest.result != UnityWebRequest.Result.Success) { Debug.LogError("❌ Error sending request to: " + url); Debug.LogError("UnityWebRequest error: " + webRequest.error); } else { Debug.Log("✅ PDF data received: " + webRequest.downloadHandler.data?.Length + " bytes"); _G.PDF = webRequest.downloadHandler.data; } WaitCircle.Setting(false, ""); } private static void OpenInputField() { Set.alpha(Get.o2("Canvas", "Panel_SCENE"), true); Get.o2("PNL", "PDFpnl").SetActive(true); Get.o2("PNL/PDFpnl", "InputPDFName").GetComponent().text = _G.FileName; if (_G.FileName == "FN") Get.o2("PNL/PDFpnl", "InputPDFName").GetComponent().text = ""; } //Dictionary protected virtual Dictionary AddFieldForRecover(string number, WWWForm form) { return MakeList.RECOVERQTY(); } protected virtual Dictionary AddFieldForKnob(string number, WWWForm form) { return MakeList.KNOBLISTQTY(); } //Add Feild Images protected int AddFieldElevation(WWWForm form) { int iteration = 1; for (int i = 1; i < _G.NW + 1; i++) { //print("i====" + i); if (BYTES[i - 1] != null) { print("i=2===" + i); string pageNumber = (i + 2).ToString(); string elevationNumber = i.ToString(); form.AddField("ele" + elevationNumber, TRANS.This("P_ELEVATION WALL") + elevationNumber); form.AddField("action" + pageNumber, "Upload Image" + pageNumber); form.AddBinaryData("fileUploadE" + elevationNumber + "2D", BYTES[i - 1], "fileUploadE" + elevationNumber + "2D.png", "image" + pageNumber + "/png"); iteration++; } } return iteration; } protected void AddFieldForIsland(WWWForm form, int iteration) { print("iteration===="+iteration); if (_islandBYTES != null) { string pageNumber = (iteration+2 ).ToString(); form.AddField("ele" + pageNumber, TRANS.This("P_ISLAND")); form.AddField("action" + pageNumber, "Upload Image" + pageNumber); form.AddBinaryData("fileUploadE" + pageNumber + "2D", _islandBYTES, "fileUploadE" + pageNumber + "2D.png", "image" + pageNumber + "/png"); } } protected virtual void AddFieldForAllPictures( WWWForm form) { if (_bytes?.Length > 0 ){print("--------------------------Not empty--------------------0-----------------");} else {print("------------------------------------------------Ok it is empty------------------------0--------------");} form.AddBinaryData("fileUpload", _bytes, "fileUpload.png", "image/png"); form.AddField("ite" + _objCount, ""); //number form.AddField("OBJcount", _objCount); form.AddField("action", "Upload Image"); form.AddField("action2", "Upload Image2"); form.AddBinaryData("fileUploadP2D", _bytesP2D, "fileUploadP2D.png", "image2/png"); } //Add Feild for List protected void AddFieldToPDF( out WWWForm form) { //url path //GameObject.Find("HIDER").transform.Find("LoadingCircle").gameObject.SetActive(true); //WaitCircle.Setting(true, TRANS.This("M_PDFCONSTRUCT") ); //string url = ThisOnly.getUrlPDF(); //number = ""; // yield return new WaitForEndOfFrame(); string Date= System.DateTime.Now.ToString("MM/dd/yyyy"); string TotalPrice="\n"+TRANS.This("P_ProjectCost")+" "+_G.PriceTotal+"\n"+TRANS.This("P_EstimationPhrase");//"***LE PRIX DOIT ETRE VALIDE EN MAGASIN - CECI EST UNE ESTIMATION ***"; //LIST //List LIST = DOLIST.CABLISTString(); form = new WWWForm(); form.AddField("T1", ""); // t1 vs T1 print("_G.StoreSelect===="+_G.StoreSelect); // form.AddField("Info1", "Info1"); // t1 vs T1 // form.AddField("Info2", "Info2."); // t1 vs T1 if(Get.PreferenceBool("STORE_SELECTION"))form.AddField("Info3", _G.StoreSelect); // t1 vs T1 // form.AddField("Info4", "Info4"); // t1 vs T1 // form.AddField("Info5", "Info5"); // t1 vs T1 print("_G.PriceTotal=="+TotalPrice); if(_P.ListSwitch["SHOW_PRICE"] && _G.PriceTotal!="0"){form.AddField("price", TotalPrice); }// t1 vs T1 form.AddField("date", TRANS.This("Date") + ": " + Date); form.AddField("qty", TRANS.This("QTY")); form.AddField("item", TRANS.This("P_Item")); form.AddField("code", TRANS.This("CODE"));// form.AddField("des", TRANS.This("DESCRIPTION")); if(_P.ListSwitch["SHOW_PRICE"]){ form.AddField("pu", TRANS.This("PRICE")); form.AddField("pt", TRANS.This("TOTAL")); } form.AddField("p2d", TRANS.This("T_PLAN 2D")); //CompleteFormInfo1To5(form); string path = "https://ukitchenit.com/members/" + _G.PATH + "/start/logopdf.png"; form.AddField("path", path); } protected void AddFieldForCab( List Cablist,WWWForm form) { Dictionary CABdict = MakeList.CABLISTQTY(Cablist); foreach (KeyValuePair pair in CABdict) { //print("pair.Key===="+pair.Key); //HH-B18 ? W18 ''x H34 3/4''x D23 5/16'' ? 1?1? Already assemble 1 door 18 base cabinet with adjustable legs?0_0_0_0_0_0_0?L?1 string PriceColumn= ""; if (Get.PreferenceBool("STORE_SELECTION")) { PriceColumn = _G.StoreZone; } string[] CODE = pair.Key.Split('?'); string[] VALUE = pair.Value.Split('?'); string number = VALUE[1]; // string Codenumber = CODE[0]; string DoorLanguage=""; //string DoorColorUniqueName=""; string DoorUniqueName=""; //string Description=""; ///Kwizine No Door----------------- string DoorColorUniqueName = TRANS.This("C_MELAMINEWHITE"); if(CODE[3]!="MELAMINEWHITE" && CODE[2]!="NO_DOOR"){ DoorColorUniqueName = UIT.Value(Library.CabTexture,CODE[3],Header.Unique_Name); } if(CODE[2]!="NO_DOOR"){ DoorLanguage = " "+UIT.Value(Library.Door,CODE[2],"L"+_G.L.ToString()); DoorColorUniqueName=" "+UIT.Value(Library.CabTexture,CODE[3],Header.Unique_Name); DoorUniqueName =" "+UIT.Value(Library.Door,CODE[2],Header.Unique_Name); } if(CODE[2]=="NO_DOOR" && CODE[3]=="MELAMINEWHITE"){ DoorUniqueName=" "+TRANS.This("L_No doors"); DoorColorUniqueName=" "+TRANS.This("L_No doors"); } if(CODE[2]=="NO_DOOR" && CODE[3]!="MELAMINEWHITE" && CODE[3].IndexOf("TEXT")==-1){ DoorUniqueName=" "+TRANS.This("L_No doors"); DoorColorUniqueName=" "+UIT.Value(Library.CabTexture,CODE[3],Header.Unique_Name); } if(CODE[2]=="NO_DOOR" && CODE[3].IndexOf("TEXT")!=-1){ DoorUniqueName=" "+TRANS.This("L_No doors"); DoorColorUniqueName=" "+TRANS.This("L_No doors"); } ///Kwizine No Door----------------- //E commerce code----------------- string PriceCode_ID= UIT.GetCabinetPriceID(CODE[0],CODE[2],CODE[3]); string CodeFromECommerce=""; if(Get.PreferenceBool("PDF_SHOW_ECOMMERCE_CODE")){ CodeFromECommerce=UIT.Value(Header.Price,PriceCode_ID,Header.Ecommerce_ID); } //Price------------------- string PriceShow=""; string UniquePriceToShow=""; float Qty=DOIT.ConvertStringToNumber(VALUE[0]); if(_P.ListSwitch["SHOW_PRICE"]){ float UniquePrice = DOIT.ConvertStringToNumber(UIT.Value(Header.Price,PriceCode_ID,Header.Price +PriceColumn)); UniquePriceToShow=UniquePrice.ToSafeString()+"$"; if(UniquePrice!=0){ float Pricetotal=Mathf.Round(UniquePrice*Qty * 100f) / 100f; PriceShow = Pricetotal.ToString("F2")+"$"; } } //Description-------------------- string Size=CODE[1]; string CabLanguage=CODE[4]; string Door_Recipe=" "+UIT.Value(Library.Cabinet,CODE[0],Header.Door_Recipe); if(UIT.Ind(Library.Cabinet,Header.Door_Recipe)==0|| CODE[2]=="NO_DOOR"){Door_Recipe="";} if(Get.PreferenceBool("CABINET_BY_MODEL_DOOR")){ DoorLanguage=" "+UIT.Value(Library.Door,CODE[2],Header.Unique_Name)+Door_Recipe; } if(Get.PreferenceBool("CABINET_BY_FINISH_BOX")){ DoorColorUniqueName=" "+UIT.Value(Library.CabTexture,CODE[3],Header.Unique_Name); } string des=TRANS.This("G_CABINET")+": "; des +=CabLanguage+DoorLanguage+" / "+DoorColorUniqueName; int DesLength=des.Length+Door_Recipe.Length+3; if(DesLength<138){des+=" "+Door_Recipe;} else des+="\n"+Door_Recipe; DesLength=des.Length+Size.Length+3; if(DesLength>138){des+=" "+Size;} else des+="\n"+Size; string Identification1 = GetIdentificationCode(1); string Identification2 = GetIdentificationCode(2); string Code= Identification1+PriceCode_ID+"\n"+Identification2+CodeFromECommerce; if(des.Length>207){des=des[..207];} //des+=DoorDescription; form.AddField("ite" + _objCount, number);//number form.AddField("c" + _objCount, Code);//Code form.AddField("d" + _objCount, des);//Description form.AddField("qty" + _objCount, Qty.ToString());//Quantity form.AddField("pu" + _objCount, UniquePriceToShow); form.AddField("pt" + _objCount, PriceShow); _objCount += 1; } } protected void AddFieldForDoor( WWWForm form) { List Cablist=DOLIST.CABLISTint(); Dictionary DOORdict = MakeList.DOORLISTQTY(Cablist); foreach (KeyValuePair pair in DOORdict) { print("pair.Key===Door="+pair.Key); //HHBC36KIT-SHA-DBS or B-MAGOG ///pair.Key===Door=HH1830-SHA-BL string PriceColumn= ""; if (Get.PreferenceBool("STORE_SELECTION")) { PriceColumn = _G.StoreZone; } bool isDoor_Group = Get.PreferenceBool("DOOR_BY_GROUP"); //Get Price_ID string[] Code= pair.Key.Split('-'); string PriceCode_ID; if (isDoor_Group){ PriceCode_ID = Code[0]; } else{PriceCode_ID = pair.Key;} //Get Door Description string DoorLanguage=UIT.Value(Library.Price,PriceCode_ID,"L"+_G.L.ToString()); //Get Color Description string Color_ID = UIT.GetIDByUnique_Name(Library.Door, Code[^1]); if(Code.Length==3){ Color_ID = Code[1] + "-" + Code[^1]; } print("Color_ID=====" + Color_ID); string ColorLanguage = UIT.Value(Library.CabTexture, Color_ID, "L" + _G.L.ToString()); //Get price-------------- string UniquePrice=""; string PriceTotal=""; int qtys = pair.Value; //ECommerce------------------- string CodeFromECommerce=""; if(Get.PreferenceBool("PDF_SHOW_ECOMMERCE_CODE")){ CodeFromECommerce=UIT.Value(Header.Price,PriceCode_ID,Header.Ecommerce_ID); } if(Get.PreferenceBool("SHOW_PRICE")){ UniquePrice = UIT.Value(Header.Price,PriceCode_ID,Header.Price +PriceColumn); if(UniquePrice!="0"){ float Pricetotal=Mathf.Round(DOIT.ConvertStringToNumber(UniquePrice)*qtys * 100f) / 100f; Pricetotal=Mathf.Round(Pricetotal * 100f) / 100f; PriceTotal=Pricetotal.ToString()+"$"; } } string des=TRANS.This("T_DOOR")+": "; des += DoorLanguage; if(des.Length<60)ColorLanguage="\n"+ColorLanguage; else ColorLanguage=" "+ColorLanguage; des+=ColorLanguage; string code=""; string Identification1 = GetIdentificationCode(1); string Identification2 = GetIdentificationCode(2); code+=Identification1+PriceCode_ID+"\n"+Identification2+CodeFromECommerce; form.AddField("ite" + _objCount, "");//number form.AddField("c" + _objCount, code);//Code form.AddField("d" + _objCount, des);//Description form.AddField("qty" + _objCount, qtys);//Quantity form.AddField("pu" + _objCount, UniquePrice); form.AddField("pt" + _objCount, PriceTotal); _objCount += 1; } } protected void AddFieldForPnl( WWWForm form) { Dictionary PNLdict = MakeList.PNLLISTQTY(); foreach (KeyValuePair pair in PNLdict) { print("Panl pair.Key====="+pair.Key);//Model ? color Panl pair.Key=====7? string[] CODE=pair.Key.Split('?'); string PanelCategory=UIT.Value(Library.Panel, CODE[0], Header.Category); string PanelUniqueName = UIT.Value(Library.Panel, CODE[0], Header.Unique_Name); if (_G.PATH == "homehardware" && PanelCategory=="DOOR") {PanelUniqueName += "-SHA";} string ColorUniqueName = UIT.Value(Library.CabTexture, CODE[1], Header.Unique_Name); string Codename=PanelUniqueName+"-"+UIT.Value(Library.CabTexture,CODE[1],Header.Unique_Name); print("Codename door====="+Codename);//HH1230-DBS vs HH1230-SHA-DBS if (!_G.LibraryItems.ContainsKey(Codename)) { // string[] CODE = pair.Key.Split('?'); // // string PanelUniqueName = UIT.Value(Library.Panel, CODE[0], Header.Unique_Name); string model = UIT.Value(Library.Panel, CODE[0], Header.Model); string Code_ID = PanelUniqueName; if (_P.ListSwitch["PANEL_BY_MODEL_COLOR"]) { Code_ID = UIT.GetPanelPriceCode_ID(PanelUniqueName, ColorUniqueName, ""); } string Wide = UIT.Value(Library.Panel, CODE[0], Header.Wide); if (Wide.Split("_").Length > 2) Wide = Wide.Split("_")[2]; string Height = UIT.Value(Library.Panel, CODE[0], Header.Height); string Thickness = UIT.Value(Library.Panel, CODE[0], Header.Thick); string Size = " " + Wide + " x " + Height + " x " + Thickness; string Category = "M_PANEL"; if (model[..2] == "D_") { Category = "M_DOOR"; Code_ID = UIT.GetPanelPriceCode_ID(PanelUniqueName, "", "SHA-" + ColorUniqueName); ;//SHA is for HomeHardware only } int Qty = pair.Value; string PriceCode_ID = UIT.GetPanelPriceCode_ID(PanelUniqueName, ColorUniqueName, ""); //Get price------------------- string UniquePrice = ""; string PriceTotal = ""; if (_P.ListSwitch["SHOW_PRICE"]) { UniquePrice = UIT.Value(Header.Price, PriceCode_ID, Header.Price + _G.StoreZone); float Pricetotal = DOIT.ConvertStringToNumber(UniquePrice) * Qty; Pricetotal = Mathf.Round(Pricetotal * 100f) / 100f; PriceTotal = Pricetotal.ToString() + "$"; } //ECommerce-------------------- string CodeFromECommerce = ""; if (_P.ListSwitch["PDF_SHOW_ECOMMERCE_CODE"]) { CodeFromECommerce = UIT.Value(Library.Price, PriceCode_ID, Header.Ecommerce_ID); } //Description-------------------- string des = ""; string PanelLanguage = " " + UIT.Value(Library.Panel, CODE[0], "L" + _G.L); string ColorLanguage = " " + UIT.Value(Library.CabTexture, CODE[1], "L" + _G.L); des += TRANS.This(Category) + ": "; if (des.Length < 120) Size = "\n" + Size; else Size = " " + Size; des += PanelLanguage + ColorLanguage + Size; string Identification1 = GetIdentificationCode(1); string Identification2 = GetIdentificationCode(2); string code = Identification1 + PriceCode_ID + "\n" + Identification2 + CodeFromECommerce; form.AddField("ite" + _objCount, "");//Code form.AddField("c" + _objCount, code);//Code form.AddField("d" + _objCount, des);//Description form.AddField("qty" + _objCount, pair.Value.ToString());//Quantity form.AddField("pu" + _objCount, UniquePrice); form.AddField("pt" + _objCount, PriceTotal); _objCount += 1; } } } protected void AddFieldForMolding(string Category,List Cablist,WWWForm form){ var Dictionary=new Dictionary(); switch(Category){ case "FILLER": Dictionary=MakeList.FILLERQTY(Cablist);break; case "VALANCE": Dictionary=MakeList.VALANCELISTQTY();break; case "FASCIA": Dictionary=MakeList.FASCIAQTY();break; case "OGEE": Dictionary=MakeList.OGEELISTQTY();break; case "KICK": Dictionary=MakeList.KICKLISTQTY(Cablist);break; } foreach (KeyValuePair pair in Dictionary) { print("Molding pair.Key===="+pair.Key); string[] Code = pair.Key.Split('?'); string CodeUniqueName=UIT.Value(Library.Molding,Code[0],Header.Unique_Name); string ColorUniqueName=UIT.Value(Library.CabTexture,Code[1],Header.Unique_Name); string Height = UIT.Value(Library.Molding,Code[0],Header.Height); string Wide = UIT.Value(Library.Molding,Code[0],Header.Wide); string Size = Height+_G.Sys+" x" + Wide+_G.Sys; float Qty = pair.Value; string Length=UIT.Value(Library.Molding,Code[0],Header.Wide); float MoldingLength=DOIT.ConvertStringToNumber(Length); float QtyLinear=pair.Value; if(Category=="FILLER"){ MoldingLength=DOIT.ConvertStringToNumber(Height); } if(!_P.ListSwitch["FILLER_BY_ITEMS"]){ Qty=Mathf.Ceil(QtyLinear/MoldingLength); } if(new List{"FASCIA","VALANCE","OGEE","KICK"}.Contains(Category)){ Qty=Mathf.Ceil(QtyLinear/MoldingLength); } string Code_ID=CodeUniqueName; if(_P.ListSwitch["MOLDING_BY_MODEL_COLOR"]){Code_ID=UIT.GetMoldingPriceCode_ID(CodeUniqueName,ColorUniqueName); } //ECommerce------------------- string CodeFromECommerce=""; if(Get.PreferenceBool("PDF_SHOW_ECOMMERCE_CODE")){ CodeFromECommerce=UIT.Value(Header.Price,Code_ID,Header.Ecommerce_ID); } //Get price------------------- string UniquePrice=""; string PriceTotal=""; if(_P.ListSwitch["SHOW_PRICE"]){ UniquePrice = UIT.Value(Header.Price,Code_ID,Header.Price +_G.StoreZone); float Pricetotal=DOIT.ConvertStringToNumber(UniquePrice)*Qty; Pricetotal=Mathf.Round(Pricetotal * 100f) / 100f; PriceTotal=Pricetotal.ToString()+"$"; } //Description-------------------- string des=TRANS.This("M_"+Category)+": "; string code=""; string PanelLanguage=" "+UIT.Value(Library.Molding,Code_ID,"L"+_G.L.ToString()); if(des.Length<120)Size="\n"+Size; else Size=" "+Size; des+= PanelLanguage + Size; string Identification1 = GetIdentificationCode(1); string Identification2 = GetIdentificationCode(2); code+=Identification1+Code_ID+"\n"+Identification2+CodeFromECommerce; form.AddField("ite" + _objCount, "");//Code form.AddField("c" + _objCount, code);//Code form.AddField("d" + _objCount, des);//Description form.AddField("qty" + _objCount, Qty.ToString());//Quantity form.AddField("pu" + _objCount, UniquePrice);//Price unit form.AddField("pt" + _objCount, PriceTotal);//Price total _objCount += 1; } } protected void AddFieldForItems( WWWForm form) { foreach (KeyValuePair pair in _G.LibraryItems ) { string des = UIT.Value(Library.Items,pair.Key,"L"+_G.L); string CodeUniqueName=UIT.Value(Library.Items,pair.Key,Header.Unique_Name); float Qty =pair.Value; //Get price string UniquePrice=""; string PriceTotal=""; if(_P.ListSwitch["SHOW_PRICE"]){ UniquePrice=UIT.Value(Library.Price,pair.Key,Header.Price +_G.StoreZone); float Pricetotal=DOIT.ConvertStringToNumber(UniquePrice)*Qty; Pricetotal=Mathf.Round(Pricetotal * 100f) / 100f; PriceTotal=Pricetotal.ToString()+"$"; } string CodeFromECommerce=""; string Code_ID=pair.Key;//IT.GetMoldingPriceCode_ID(CodeUniqueName,ColorUniqueName); string Identification1 = GetIdentificationCode(1); string Identification2 = GetIdentificationCode(2); if(_P.ListSwitch["PDF_SHOW_ECOMMERCE_CODE"]){ CodeFromECommerce=UIT.Value(Library.Price,Code_ID,Header.Ecommerce_ID); } des = pair.Key+ "\n" + des; string code=Identification1+Code_ID+"\n"+Identification2+CodeFromECommerce; form.AddField("ite" + _objCount, "");//Code form.AddField("c" + _objCount, code);//Code form.AddField("d" + _objCount, des);//Description form.AddField("qty" + _objCount, Qty.ToString());//Quantity form.AddField("pu" + _objCount, UniquePrice);//Price unit form.AddField("pt" + _objCount, PriceTotal);//Price total _objCount += 1; } } protected string GetIdentificationCode(int Ind){ if(_G.PATH=="homehardware"){ if(Ind==1)return "Jerco: "; if(Ind==2)return "HH: "; } return ""; } protected void ReturnCameraToInitialPosition() { Camera.main.transform.SetPositionAndRotation(_originalCameraPosition, _originalCameraRotation); //Get.o1("MainCamera").GetComponent().cullingMask &= ~(1 << 17);//Layer ColorWallBleeding Hide } public static void CompleteFormInfo1To5(WWWForm form) { form.AddField("Info1", _G.ClientInfo["Name"]+ " ");//+ TRANS.This("F_Jobnumber")+": "+_G.ClientInfo["JobNumber"] ); form.AddField("Info2", _G.ClientInfo["Address"]); form.AddField("Info3", _G.ClientInfo["Email"]); form.AddField("Info4", _G.ClientInfo["Phone"]); form.AddField("Info5", _G.ClientInfo["Note"]); } public static void CompleteAdress(WWWForm form) { string Address=""; string[] line = UIT.GetLibraryLine(Library.Store,_G.StoreSelect); if(line!=null){ Address=line[0]+"\n"+line[1]+"\n"+line[2]+"\n" +line[3]; } form.AddField("address",Address); } protected void SetSceneViewUpFront(bool isShow) { Set.alpha(Get.o2("Canvas", "Panel_SCENE"), isShow); Set.alpha(Get.o2("Canvas", "Language"), isShow); Get.o2("HIDER", "LoadingCircle").SetActive(isShow); //WaitCircle.Setting(true, TRANS.This("M_PDFCONSTRUCT") ); } }