app/Http/Controllers/BrightpearlController.php
// This methos is user to send notification to client to inform that initial sync has been done.
This methos is user to send notification to client to inform that initial sync has been done.
This methos is user to send notification to client to inform that initial sync has been done .
public function sendAcSyncedEmail($user_id=''){
			if($user_id){
			   	$users = $this->obj->getResultByConditions('users',['status'=>1,'id'=>$user_id], ['org_id', 'email']);
			}else{
				$users = $this->obj->getResultByConditions('users',['status'=>1], ['org_id', 'email']);
			}
			foreach($users as $uv){
				$bp_ac = $this->obj->getFirstResultByConditions('api_config',['organization_id'=>$uv->org_id,'api_provider'=>'brightpearl','sync_completed'=>1,'status'=>1], ['id', 'mail_notified']);
				$sf_ac = $this->obj->getFirstResultByConditions('api_config',['organization_id'=>$uv->org_id,'api_provider'=>'shopify','sync_completed'=>1,'status'=>1], ['id', 'mail_notified']);
				if($bp_ac && $sf_ac){
					if ($bp_ac->mail_notified=='0' || $sf_ac->mail_notified=='0'){
						$email = $uv->email;
						$final_arr = ['reason' => "Initial Sync Completed"];
						try {
							Mail::send('emails.configure_email_notification', ['data' => $final_arr], function ($msg) use ($email) {
								$msg->to($email);
								$msg->subject("Shopify-Brightpearl - Initial Sync Completed");
								$msg->from(env('MAIL_FROM_ADDRESS'), env('MAIL_FROM_NAME'));
							});
							$this->obj->makeUpdate('api_config',['mail_notified' => 1],['id'=>$sf_ac->id]);
							$this->obj->makeUpdate('api_config',['mail_notified' => 1],['id'=>$bp_ac->id]);
						} catch (\Exception $e) {
						}
					}
				}
			}
		}
public function sendAcSyncedEmail ( $ user_id = '' ) { if ( $ user_id ) { $ users = $ this -> obj -> getResultByConditions ( 'users' , [ 'status' => 1 , 'id' => $ user_id ] , [ 'org_id' , 'email' ] ) ; } else { $ users = $ this -> obj -> getResultByConditions ( 'users' , [ 'status' => 1 ] , [ 'org_id' , 'email' ] ) ; } foreach ( $ users as $ uv ) { $ bp_ac = $ this -> obj -> getFirstResultByConditions ( 'api_config' , [ 'organization_id' => $ uv -> org_id , 'api_provider' => 'brightpearl' , 'sync_completed' => 1 , 'status' => 1 ] , [ 'id' , 'mail_notified' ] ) ; $ sf_ac = $ this -> obj -> getFirstResultByConditions ( 'api_config' , [ 'organization_id' => $ uv -> org_id , 'api_provider' => 'shopify' , 'sync_completed' => 1 , 'status' => 1 ] , [ 'id' , 'mail_notified' ] ) ; if ( $ bp_ac && $ sf_ac ) { if ( $ bp_ac -> mail_notified == '0' || $ sf_ac -> mail_notified == '0' ) { $ email = $ uv -> email ; $ final_arr = [ 'reason' => " Initial Sync Completed " ] ; try { Mail :: send ( 'emails.configure_email_notification' , [ 'data' => $ final_arr ] , function ( $ msg ) use ( $ email ) { $ msg -> to ( $ email ) ; $ msg -> subject ( " Shopify-Brightpearl - Initial Sync Completed " ) ; $ msg -> from ( env ( 'MAIL_FROM_ADDRESS' ) , env ( 'MAIL_FROM_NAME' ) ) ; } ) ; $ this -> obj -> makeUpdate ( 'api_config' , [ 'mail_notified' => 1 ] , [ 'id' => $ sf_ac -> id ] ) ; $ this -> obj -> makeUpdate ( 'api_config' , [ 'mail_notified' => 1 ] , [ 'id' => $ bp_ac -> id ] ) ; } catch ( \ Exception $ e ) { } } } } }
This methos is user to send notification to client to inform that initial sync has been done.
This methos is user to send notification to client to inform that initial sync has been done .
// echo $e;