Jump to content

Recommended Posts

Posted

I have been trying really hard but I cannot for the life of me figure out how to pass the order_id. I am trying to pass the order_id or any type of identifier really. 

When using Add it gives more than enough information, However Edit is very limited and has been giving me a hard time. I need to know which order_id the client is working with through POST as a simple clientid is not enough for me to specify which product they are using. Originally I would use what the client named their server which worked but if they choose to edit the name of the server...well it doesn't pass the old one. I tried using the client id and the date they got the order which works but edit does not pass date added.

 

I decided, okay maybe qty has a hint for me and I decided to edit the plugin directly which KIND OF worked:

 private static $reserved_fields = array('qty','date_added','client_id','id','id_code');

from

private static $reserved_fields = array('qty');

and placed those in the service field similar to what qty requests. date_added and client_id are the only ones that ended up working but, 

they would request for information in the fields! When I left them blank and set them as secret or any configuration really it wouldn't work  or would show up blank but when I allowed admins to add variables into them, the date_added would just pass the current time stamp and client_id would just say "the client does not exist" until you entered a correct client ID.

 

I just want: {order.number} to populate in the POST arrays found here:

https://docs.blesta.com/display/user/Order+System

 

and it's driving me crazy. I'm one variable away from finishing my script. :(

Posted

The order ID wouldn't be available in service notifications. I think you'd want to reference the service ID, which is not included at the moment. See CORE-1698. You can include it and any other fields by updating the module yourself to pass it along--look into UniversalModule::sendNotification and UniversalModule::processPackage.

Posted

I also use client custom fields, in a way like you want.

In database table "client_fields", id are manually modified for having a given display order like for each service type n°1 (from 100 to 199) servive type n°2 (from 200 to 299), etc..

see picture 1, picture 2

Each service type have his own package group for trial or paid version

A mysql trigger set the custom field status ( 100 , 200, 300) for have automatically the service status (active /suspended, etc...) from the "services" database table automatically after each update:

CREATE TRIGGER update_connectors_status
AFTER UPDATE ON services
FOR EACH ROW
BEGIN

IF (NEW.status <> OLD.status) THEN


              IF (NEW.package_group_id = '18' OR NEW.package_group_id = '19') THEN
       
                                 IF (SELECT COUNT(*) FROM services WHERE (package_group_id = '18' OR package_group_id = '19') AND status = 'active' AND client_id = NEW.client_id) = 0 THEN
       
                                                IF (SELECT COUNT(*) FROM client_values WHERE client_field_id = '100' AND client_id = NEW.client_id) = 0 THEN
                                                             INSERT INTO client_values (client_field_id, client_id, value)
                                                             VALUES ('100', NEW.client_id, NEW.status);
                                                ELSE
                                                              UPDATE client_values SET value = NEW.status WHERE client_field_id = '100' AND client_id = NEW.client_id;
                                                 END IF;    
               
               
                                  ELSE
       
                                                       
                                                 IF (SELECT COUNT(*) FROM client_values WHERE client_field_id = '100' AND client_id = NEW.client_id) = 0 THEN
                                                               INSERT INTO client_values (client_field_id, client_id, value)
                                                               VALUES ('100', NEW.client_id, 'active');
                                                 ELSE                                                                                                    
                                                              UPDATE client_values SET value = 'active' WHERE client_field_id = '100' AND client_id = NEW.client_id;                                                         
                                                 END IF;                
 	                      
                                  END IF;	
                                  
                                  
                  
                  
               ELSEIF (NEW.package_group_id = '20') THEN            
  
  
                                 IF (SELECT COUNT(*) FROM services WHERE package_group_id = '20' AND status = 'active' AND client_id = NEW.client_id) = 0 THEN
       
                                                IF (SELECT COUNT(*) FROM client_values WHERE client_field_id = '200' AND client_id = NEW.client_id) = 0 THEN
                                                             INSERT INTO client_values (client_field_id, client_id, value)
                                                             VALUES ('200', NEW.client_id, NEW.status);
                                                ELSE
                                                              UPDATE client_values SET value = NEW.status WHERE client_field_id = '200' AND client_id = NEW.client_id;
                                                 END IF;    
               
               
                                  ELSE
       
                                                       
                                                 IF (SELECT COUNT(*) FROM client_values WHERE client_field_id = '200' AND client_id = NEW.client_id) = 0 THEN
                                                               INSERT INTO client_values (client_field_id, client_id, value)
                                                               VALUES ('200', NEW.client_id, 'active');
                                                 ELSE                                                                                                    
                                                              UPDATE client_values SET value = 'active' WHERE client_field_id = '200' AND client_id = NEW.client_id;                                                         
                                                 END IF;                
 	                      
                                  END IF;	  
  
        


              ELSEIF (NEW.package_group_id = '22' OR NEW.package_group_id = '23') THEN
       
                                 IF (SELECT COUNT(*) FROM services WHERE (package_group_id = '22' OR package_group_id = '23') AND status = 'active' AND client_id = NEW.client_id) = 0 THEN
       
                                                IF (SELECT COUNT(*) FROM client_values WHERE client_field_id = '300' AND client_id = NEW.client_id) = 0 THEN
                                                             INSERT INTO client_values (client_field_id, client_id, value)
                                                             VALUES ('300', NEW.client_id, NEW.status);
                                                ELSE
                                                              UPDATE client_values SET value = NEW.status WHERE client_field_id = '300' AND client_id = NEW.client_id;
                                                 END IF;    
               
               
                                  ELSE
       
                                                       
                                                 IF (SELECT COUNT(*) FROM client_values WHERE client_field_id = '300' AND client_id = NEW.client_id) = 0 THEN
                                                               INSERT INTO client_values (client_field_id, client_id, value)
                                                               VALUES ('300', NEW.client_id, 'active');
                                                 ELSE                                                                                                    
                                                              UPDATE client_values SET value = 'active' WHERE client_field_id = '300' AND client_id = NEW.client_id;                                                         
                                                 END IF;                
 	                      
                                  END IF;

   	
             
              END IF;	 


              
              
END IF;     	
END ;

In the customer area & template for display client custom fields, I use the custom field id to order regroug display/hide field by block of service and only display if they are active or not (custom field id (100, 200, 300) value).

 

see picture 3

 

post-10846-0-55079300-1448094084_thumb.p

post-10846-0-86307100-1448094166_thumb.p

post-10846-0-70230700-1448094169_thumb.p

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...