{'folder_name'}) { case 'Merchant Contract': $contractFolderID = $arrFolders->{'id'}; break; case 'ID': $idFolderID = $arrFolders->{'id'}; break; case 'Selfie': $PersonPicFolderID = $arrFolders->{'id'}; break; case 'Proof of Residence': $popFolderID = $arrFolders->{'id'}; break; case 'Signature': $SignatureID= $arrFolders->{'id'}; break; default: break; } if (count($arrFolders->{'folders'}) > 0) { manipulateSubFolderStructure($arrFolders->{'folders'}); } }, $folderStructure); } $upload_path = $rootbase . 'ficapics/'; $folderName; $popFolderID = null; $PersonPicFolderID = null; $idFolderID = null; $contractFolderID = null; $SignatureID = null; $safe4FilePathID = ''; $safe4FilePathPic = ''; $safe4FilePathPop = ''; $safe4FilePathContract = ''; $safe4FilePathCustSig = ''; $safe4FilePathRepSig = ''; $result3 = mysqli_query($con, "select Value from setting where setting.Key='providerID' "); $result4 = mysqli_fetch_array($result3, MYSQLI_ASSOC); $providerIDValue = $result4['Value']; $providerID = $providerIDValue; $safe4 = new Safe4Controller('username', 'api_key'); $sessionKey = $safe4->getSessionKey(); $custDetails = mysqli_query($con,"SELECT t1.Customer_ID ,t1.Merchant_Code ,t1.Customer_Name ,t1.Customer_Last_Name ,t1.Pic_ID_Doc ,t1.Pic_Proof_of_Address ,t1.Pic_of_person ,t1.Customer_Contract ,t1.cust_signature ,t1.rep_signature FROM customer t1 WHERE t1.Customer_ID = '101408125'" ); while ($custDetail = mysqli_fetch_array($custDetails)) { $customerId = $custDetail['Customer_ID']; $Merchant_Code = $custDetail['Merchant_Code']; $Customer_Name = $custDetail['Customer_Name']; $Customer_Last_Name = $custDetail['Customer_Last_Name']; $idPic = $upload_path . $custDetail['Pic_ID_Doc']; $popPic = $upload_path . $custDetail['Pic_Proof_of_Address']; $personPic = $upload_path . $custDetail['Pic_of_person']; $custContract = $upload_path . $custDetail['Customer_Contract']; $custSigPic = $upload_path . $custDetail['cust_signature']; $repSigPic = $upload_path . $custDetail['rep_signature']; $company_name = $Merchant_Code . '_' . $Customer_Name . '_' . $Customer_Last_Name.time(); $vaultResponse = $safe4->createVaultCopyStructure($providerID, $company_name, $sessionKey); if (isset($vaultResponse['id'])) { $vaultID = $vaultResponse['id']; $folderStructure = $safe4->getFolderStructure($providerID, $vaultID, $sessionKey); $decodedFolders = json_decode($folderStructure); $foldersOnly = $decodedFolders->{'folders'}; $folderName = 'Contract'; manipulateSubFolderStructure($foldersOnly); } if (file_exists($repSigPic)) { if (isset($contractFolderID)) { $fileName = $Merchant_Code . '_' . basename($repSigPic); $filePath = $upload_path."rep_signature/" . basename($repSigPic); $safe4FilePathRepSig = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $SignatureID); if (isset($safe4FilePathRepSig)) { unlink($filePath); } } } if (file_exists($custSigPic)) { if (isset($contractFolderID)) { $fileName = $Merchant_Code . '_' . basename($custSigPic); $filePath = $upload_path."signature/" . basename($custSigPic); $safe4FilePathCustSig = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $SignatureID); if (isset($safe4FilePathCustSig)) { unlink($filePath); } } } if (file_exists($custContract)) { if (isset($contractFolderID)) { $fileName = $Merchant_Code . '_' . basename($custContract); $filePath = $upload_path."pop/" . basename($custContract); $safe4FilePathContract = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $contractFolderID); if (isset($safe4FilePathContract)) { unlink($filePath); } } } if (file_exists($idPic)) { if (isset($idFolderID)) { $fileName = $Merchant_Code . '_' . basename($idPic); $filePath = $upload_path."id/" . basename($idPic); $safe4FilePathID = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $idFolderID); if (isset($safe4FilePathID)) { unlink($filePath); } } } if (file_exists($personPic)) { if (isset($PersonPicFolderID)) { $fileName = $Merchant_Code . '_' . basename($personPic); $filePath = $upload_path."personpic/" . basename($personPic); $safe4FilePathPic = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $PersonPicFolderID); if (isset($safe4FilePathPic)) { unlink($filePath); } } } if (file_exists($popPic)) { if (isset($popFolderID)) { $fileName = $Merchant_Code . '_' . basename($popPic); $filePath = $upload_path."pop/" . basename($popPic); $safe4FilePathPop = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $popFolderID); if (isset($safe4FilePathPop)) { unlink($filePath); } } } $result=mysqli_query($con,"INSERT INTO ricaregistrationdocs (id,CustomerID,VaultID,FolderId,UrlId,PersonpicFolderId,PersonpicUrl,PopFolderId,PopUrl,ContractFolderId,ContractUrl,SessionKey) VALUES (NULL, '$customerId', '$vaultID','$idFolderID','$safe4FilePathID','$PersonPicFolderID','$safe4FilePathPic','$popFolderID','$safe4FilePathPop','$contractFolderID','$safe4FilePathContract','$sessionKey')"); }