GUIDE TO UPDATE KMRS WITH MOBILE APP V2

Please do the following steps

  1. Update your KMRS config open the file protected/config/main.php
    in array noCsrfValidationRoutes add the following
    
    'mobileappv2/api', 
    'mobileappv2/voguepay',
    'mobileappv2/braintree',
    'mobileappv2/ajax/uploadFile',
    
    
    full example
    
    'components'=>array(		   
    	    'request'=>array(
    	        'class' => 'application.components.HttpRequest',
                'enableCsrfValidation'=>true,
                'noCsrfValidationRoutes'=>array(	            
    	            'ajaxadmin/uploadFile',
    	            'ajaxmerchant/uploadFile',
    	            'ajaxmerchant/MultipleUploadFile',
    	            'ajax/UploadProfile',
    	            'ajax/UploadDeposit',
    	            'mobileapp/ajax/upload',
    	            'singlemerchant/api',	            
    	            'driver/ajax/uploadprofilephoto',
    	            'driver/ajax/uploadCertificate',
    	            'exportmanager/ajax/importMerchant',
    	            'mobileapp/api',	
    	            'merchantapp/api',
    	            'driver/api',
    	            'store/voginit',
                    'store/vognotify',
                    'store/vogsuccess',
                    'store/voguepaynotify',
                    'store/voguepaysuccess',
                    'store/voguepayfailed',
                    'store/merchantsignup',
                    'stripe/webhooks',
                    'merchant/vogsuccess',
                    'admin/merchantAddBulk',
                    'mobileapp/voguepay',
                    'mobileapp/braintree',
                    'store/epaybg',
                    'store/mollie_webhook',
                    'singlemerchant/ajax/upload',
                    'singlemerchant/voguepay',
                    'singlemerchant/braintree',
                    'store/payuinit',
                    'merchant/payuinit',                
                    'mobileappv2/api', 
                    'mobileappv2/voguepay',
                    'mobileappv2/braintree',
                    'mobileappv2/ajax/uploadFile',                
    	        ),
            ),
            'session' => array(
    	        'timeout' => 86400,
    	    ),
    
    
  2. Update the KMRS with order updates notification

    open the file protected/components/FunctionsV3.php
    and look for function notifyCustomerOrderStatusChange after the code

    
    
    
    if (FunctionsV3::hasModuleAddon("singlemerchant")){
    
      //code for single merchant push
    
    }
    
    
    
    
    add the following code
    
    
    
    /*MOBILE VERSION 2*/
    
    if (FunctionsV3::hasModuleAddon("mobileappv2")){
    
    	Yii::app()->setImport(array(			
    
    	  'application.modules.mobileappv2.components.*',
    
    	));
    
    	if(method_exists('mobileWrapper','OrderTrigger')){	    				    			
    
    		mobileWrapper::OrderTrigger($order_id,$status,$remarks);
    
    	}
    
    }
    
    
    
    

  3. Send notification for booking

    open the file protected/components/FunctionsV3.php
    and look for function updateBookingNotify after the code

    
    
    
    if (FunctionsV3::hasModuleAddon("singlemerchant")){
    
      //code for single merchant push
    
    }
    
    
    
    
    add the following code
    
    
    
    /*MOBILE VERSION 2*/
    
    if (FunctionsV3::hasModuleAddon("mobileappv2")){
    
    	Yii::app()->setImport(array(			
    
    	  'application.modules.mobileappv2.components.*',
    
    	));			
    
    	if(method_exists('mobileWrapper','OrderTrigger')){	    				    			
    
    		mobileWrapper::OrderTrigger($data['booking_id'],$data['remarks'],'','booking');
    
    	}
    
    }
    
    
    
    

  4. Send notificatin for order cancellation

    open the file protected/components/FunctionsV3.php
    and look for function notifyCustomerCancelOrder after the code

    
    
    
    if (FunctionsV3::hasModuleAddon('mobileapp')){
    
      //code for mobile app
    
    }
    
    
    
    
    add the following code
    
    
    
    /*MOBILE VERSION 2*/
    
    if (FunctionsV3::hasModuleAddon("mobileappv2")){
    
    	Yii::app()->setImport(array(			
    
    	  'application.modules.mobileappv2.components.*',
    
    	));
    
    	if(method_exists('mobileWrapper','OrderTrigger')){	    				    			
    
    		mobileWrapper::OrderTrigger($data['order_id'],$cancel_status,'','order_request_cancel');
    
    	}
    
    }
    
    
    
    

  5. Update KMRS with new banner menu in merchant panel

    Open the file components/functions.php and look for the line

    
    
    
    array('visible'=>FunctionsV3::hasMerchantAccessToMenu($user_access,"gallerysettings"),'tag'=>"gallerysettings",'label'=>''.Yii::t("default","Gallery Settings"),
    
    'url'=>array('/merchant/gallerysettings')),
    
    
    
    
    and add the following code
    
    
    
    array('visible'=>FunctionsV3::hasMerchantAccessToMenu($user_access,"banner_settings"),'tag'=>"banner_settings",'label'=>''.Yii::t("default","Banner Settings"),
    
    'url'=>array('/merchant/banner_settings')),
    
    
    
    
    open the file controller/MerchantController.php and add this new functions
    
    
    
    public function actionbanner_settings()
    
    {
    
    	$merchant_id = Yii::app()->functions->getMerchantID();
    
    	$this->crumbsTitle = t("Banner Settings");
    
    	$this->render('banner-settings',array(
    
    	  'merchant_id'=>$merchant_id,
    
    	  'banner'=>getOption($merchant_id,'merchant_banner'),
    
    	  'banner_enabled'=>getOption('','banner_enabled'),		  
    
    	));
    
    }
    
    
    
    
    and create a file called banner-settings.php in the folder views/merchant/banner-settings.php you can get the content of this file on this link http://bastisapp.com/helpfiles/banner-settings.phps open the file components/Ajax.php and add the new functions at the very end
    
    
    
    public function BannerSettings()
    
    {
    
    	$merchant_id=Yii::app()->functions->getMerchantID();
    
    	if($merchant_id>=1){
    
    		
    
    		$old_data=getOption($merchant_id,'merchant_banner');
    
    		if(!empty($old_data)){
    
    			$old_data=json_decode($old_data,true);
    
    		}		
    
    		
    
    		/*DELETE IMAGE*/
    
    		if(is_array($old_data) && count($old_data)>=1 && !empty($this->data['photo'])){
    
    			foreach ($old_data as $val) {
    
    				if(!in_array($val,(array)$this->data['photo'])){				
    
    	    	        FunctionsV3::deleteUploadedFile($val);
    
    				}				
    
    			}
    
    		}			
    
    		
    
    		Yii::app()->functions->updateOption("merchant_banner",
    
        	isset($this->data['photo'])?json_encode($this->data['photo']):''
    
        	,$merchant_id);
    
        	
    
        	Yii::app()->functions->updateOption("banner_enabled",
    
        	isset($this->data['banner_enabled'])?$this->data['banner_enabled']:''
    
        	,$merchant_id);
    
    		
    
    		$this->code=1;
    
    	    $this->msg=Yii::t("default","Setting saved");
    
    	} else $this->msg = t("invalid merchant id");
    
    }
    
    
    
    

UPDATE YOUR DRIVER APP ADDON

  1. Open the file modules/driver/components/Driver.php and look for function sendNotificationCustomer add the new code below starting with /*MOBILE VERSION 2*/
    
    
    
    	/*SEND PUSH*/
    
    		$key_is_enabled=getOptionA($key."_PUSH");					
    
    		if ( $key_is_enabled==1 && $info['order_id']>0){			
    
    			$message=getOptionA($key."_PUSH_TPL");			
    
    			$message=self::smarty('TaskID',$info['task_id'],$message);
    
    			$message=self::smarty('CustomerName',$info['customer_name'],$message);
    
    			$message=self::smarty('CustomerAddress',$info['delivery_address'],$message);
    
    			$message=self::smarty('DeliveryDateTime',self::prettyDate($info['delivery_date']),$message);
    
    			$message=self::smarty('PickUpDateTime',self::prettyDate($info['delivery_date']),$message);
    
    			$message=self::smarty('DriverName',$info['driver_name'],$message);
    
    			$message=self::smarty('DriverPhone',$info['driver_phone'],$message);
    
    			$message=self::smarty('OrderNo',$info['order_id'],$message);
    
    			$message=self::smarty('CompanyName',getOptionA('website_title'),$message);				
    
    			if ( FunctionsV3::hasModuleAddon('mobileapp')){
    
    				if ( $client=self::getCustomerInformationByOrderID($info['order_id'])){		
    
    					
    
    					$push_title =  str_replace("_"," ",$key);					
    
    					$push_title = self::t($push_title);
    
    								
    
    					$params=array(
    
    					  'client_id'=>$client['client_id'],
    
    					  'client_name'=>$client['client_name'],
    
    					  'device_platform'=>$client['device_platform'],
    
    					  'device_id'=>$client['device_id'],
    
    					  'push_title'=>$push_title,
    
    					  'push_message'=>$message,
    
    					  'date_created'=>FunctionsV3::dateNow(),
    
    					  'ip_address'=>$_SERVER['REMOTE_ADDR']
    
    					);					
    
    					$db_ext->insertData("{{mobile_push_logs}}",$params);
    
    				}
    
    			}			
    
    			
    
    			/*SEND PUSH TO SINGLEAPP*/			
    
    			if ( FunctionsV3::hasModuleAddon('singlemerchant')){
    
    				if ($single_resp = self::getSingleAppDeviceIDByOrderID($info['order_id'])){					
    
    					$params_single=array(
    
    					  'client_id'=>$single_resp['client_id'],
    
    					  'client_name'=>$single_resp['client_name'],
    
    					  'device_platform'=>$single_resp['device_platform'],
    
    					  'device_id'=>$single_resp['device_id'],
    
    					  'push_title'=>$push_title,
    
    					  'push_message'=>$message,
    
    					  'date_created'=>FunctionsV3::dateNow(),
    
    					  'ip_address'=>$_SERVER['REMOTE_ADDR'],
    
    					  'merchant_id'=>$single_resp['merchant_id'],
    
    					);					
    
    					$db_ext->insertData("{{singleapp_mobile_push_logs}}",$params_single);
    
    				}					
    
    			}			
    
    			
    
    			/*MOBILE VERSION 2*/
    
    			if (FunctionsV3::hasModuleAddon("mobileappv2")){
    
    				Yii::app()->setImport(array(			
    
    				  'application.modules.mobileappv2.components.*',
    
    				));
    
    				if(method_exists('mobileWrapper','OrderTrigger')){	    				    			
    
    					mobileWrapper::OrderTrigger($info['order_id'],$key,'','driver');
    
    				}
    
    			}
    
    					
    
    		}