diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index cbaac1b..3ab8eeb 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -435,28 +435,40 @@ class ClientController extends BaseController "created_by" => $created_by, "business_id" => $business_id, ]; + $client_pan_find = $this->ClientModel->where('pan_no', $value['pan_no'])->first(); - $client = $this->ClientModel->insert($insertData); - if($client){ - if($value['branches']){ - foreach ($value['branches'] as $key => $branch) { - $insertBranchData = [ - "name" => $branch['b_name'], - "gst_no" => $branch['gst_no'], - "email" => $branch['b_email'], - "mobile_no" => $branch['b_mobile_no'], - "created_by" => $created_by, - "client_id" => $client, - "country" => $branch['country'], - "state" => $branch['state'], - "city" => $branch['city'], - "pin_code" => $branch['pin_code'], - "address" => $branch['address'], - ]; - $clientBranch = $this->ClientBranchModel->insert($insertBranchData); + if($client_pan_find){ + + }else{ + $client = $this->ClientModel->insert($insertData); + if($client){ + if($value['branches']){ + foreach ($value['branches'] as $key => $branch) { + $insertBranchData = [ + "name" => $branch['b_name'], + "gst_no" => $branch['gst_no'], + "email" => $branch['b_email'], + "mobile_no" => $branch['b_mobile_no'], + "created_by" => $created_by, + "client_id" => $client, + "country" => $branch['country'], + "state" => $branch['state'], + "city" => $branch['city'], + "pin_code" => $branch['pin_code'], + "address" => $branch['address'], + ]; + + if($this->ClientBranchModel->where('gst_no', $branch['gst_no'])->first()){ + + }else{ + $clientBranch = $this->ClientBranchModel->insert($insertBranchData); + } + } } } } + + } return json_encode(true); } else {