From 59b072d1382e8267aaadeb763f195a4068b8b92a Mon Sep 17 00:00:00 2001
From: Uma <uma.s@vtiger.com>
Date: Fri, 10 Apr 2020 12:38:57 +0530
Subject: [PATCH] Fixes #1250 Import bug of record sequence numbering

---
 data/CRMEntity.php | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/data/CRMEntity.php b/data/CRMEntity.php
index bfd70408c..a11a3ea99 100644
--- a/data/CRMEntity.php
+++ b/data/CRMEntity.php
@@ -1605,7 +1605,7 @@ class CRMEntity {
 					while ($recordinfo = $adb->fetch_array($records)) {
 						$value = "$prefix" . "$cur_id";
 						$adb->pquery("UPDATE $fld_table SET $fld_column = ? WHERE $this->table_index = ?", Array($value, $recordinfo['recordid']));
-						$cur_id += 1;
+						$cur_id = $this->getSequnceNumber($cur_id);
 						$returninfo['updatedrecords'] = $returninfo['updatedrecords'] + 1;
 					}
 					if ($old_cur_id != $cur_id) {
@@ -1618,6 +1618,15 @@ class CRMEntity {
 		}
 		return $returninfo;
 	}
+    
+    function getSequnceNumber($curid){
+        $strip = strlen($curid) - strlen($curid + 1);
+        if ($strip < 0)
+                $strip = 0;
+        $temp = str_repeat("0", $strip);
+        $req_no = $temp . ($curid + 1);
+        return $req_no;
+    }
 
 	/* Generic function to get attachments in the related list of a given module */
 
-- 
GitLab