{'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 ,t1.Customer_Type ,t1.Reg_Type ,t1.Status FROM customer t1 LEFT JOIN ricaregistrationdocs t2 ON t2.CustomerID = t1.Customer_ID WHERE (t1.Reg_Type IS NOT NULL OR t1.Customer_Type = 560) AND t1.Status NOT IN ('DECLINED', 'INCOMPLETE', 'DEACTIVATE') AND t2.id IS NULL" ); 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 =$custDetail['Pic_ID_Doc']; $popPic = $custDetail['Pic_Proof_of_Address']; $personPic =$custDetail['Pic_of_person']; $custContract = $custDetail['Customer_Contract']; $custSigPic =$custDetail['cust_signature']; $repSigPic =$custDetail['rep_signature']; $company_name = $Merchant_Code . '_' . $Customer_Name . '_' . $Customer_Last_Name.time(); $vaultResponse = $safe4->createVaultCopyStructure($providerID, $company_name, $sessionKey); echo $company_name . "\n"; if (isset($vaultResponse['id'])) { $vaultID = $vaultResponse['id']; echo $vaultID . "\n"; $folderStructure = $safe4->getFolderStructure($providerID, $vaultID, $sessionKey); $decodedFolders = json_decode($folderStructure); $foldersOnly = $decodedFolders->{'folders'}; $folderName = 'Contract'; manipulateSubFolderStructure($foldersOnly); } echo $repSigPic . "\n"; $ext = pathinfo($repSigPic, PATHINFO_EXTENSION); if (isset($repSigPic)) { if ($ext !=''){ if (isset($contractFolderID)) { $fileName = $Merchant_Code . '_' . basename($repSigPic); $filePath = $upload_path."rep_signature/" . basename($repSigPic); echo $filePath . "\n"; $safe4FilePathRepSig = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $SignatureID); if (isset($safe4FilePathRepSig)) { unlink($filePath); } } } } echo $custSigPic . "\n"; $ext = pathinfo($custSigPic, PATHINFO_EXTENSION); if (isset($custSigPic)) { if ($ext !=''){ if (isset($contractFolderID)) { $fileName = $Merchant_Code . '_' . basename($custSigPic); $filePath = $upload_path."signature/" . basename($custSigPic); echo $filePath . "\n"; $safe4FilePathCustSig = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $SignatureID); if (isset($safe4FilePathCustSig)) { unlink($filePath); } } } } echo $custContract . "\n"; $ext = pathinfo($custContract, PATHINFO_EXTENSION); if (isset($custContract)) { if ($ext !=''){ if (isset($contractFolderID)) { $fileName = $Merchant_Code . '_' . basename($custContract); $filePath = $upload_path."pop/" . basename($custContract); echo $filePath . "\n"; $safe4FilePathContract = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $contractFolderID); if (isset($safe4FilePathContract)) { unlink($filePath); } } } } echo $idPic . "\n"; $ext = pathinfo($idPic, PATHINFO_EXTENSION); if (isset($idPic)) { if ($ext !=''){ if (isset($idFolderID)) { $fileName = $Merchant_Code . '_' . basename($idPic); $filePath = $upload_path."id/" . basename($idPic); echo $filePath . "\n"; $safe4FilePathID = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $idFolderID); if (isset($safe4FilePathID)) { unlink($filePath); } } } } echo $personPic . "\n"; $ext = pathinfo($personPic, PATHINFO_EXTENSION); if (isset($personPic)) { if ($ext !=''){ if (isset($PersonPicFolderID)) { $fileName = $Merchant_Code . '_' . basename($personPic); $filePath = $upload_path."personpic/" . basename($personPic); echo $filePath . "\n"; $safe4FilePathPic = $safe4->uploadDocument($providerID, $vaultID, $sessionKey, $filePath, $fileName, $PersonPicFolderID); if (isset($safe4FilePathPic)) { unlink($filePath); } } } } echo $popPic . "\n"; $ext = pathinfo($popPic, PATHINFO_EXTENSION); if (isset($popPic)) { if ($ext !=''){ if (isset($popFolderID)) { $fileName = $Merchant_Code . '_' . basename($popPic); $filePath = $upload_path."pop/" . basename($popPic); echo $filePath . "\n"; $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,RepsidFolderId,RepsigUrl,CustsigFolderId,CustsigUrl) VALUES (NULL, '$customerId', '$vaultID','$idFolderID','$safe4FilePathID','$PersonPicFolderID','$safe4FilePathPic','$popFolderID','$safe4FilePathPop','$contractFolderID','$safe4FilePathContract','$sessionKey','$SignatureID','$safe4FilePathRepSig','$SignatureID','$safe4FilePathCustSig')"); echo "Values inserted into database" . "\n"; }