Przeglądaj źródła

170105

GE eSign test version 1.0.170104
Ray Zhang 9 lat temu
rodzic
commit
dfbecbfd13

+ 29 - 5
Ants Contract/common/DocumentListViewController.m

@@ -462,7 +462,7 @@
 //    [creatorlabel sizeToFit];
 //    [myView addSubview:creatorlabel];
     
-    UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(300, 11, 150, 22)];
+    UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(350, 11, 150, 22)];
     
     contactlabel.textColor=UIColorFromRGB(color);
     contactlabel.backgroundColor = [UIColor clearColor];
@@ -486,7 +486,7 @@
     //    [modellabel sizeToFit];
     //    [myView addSubview:modellabel];
     
-    UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.tableView.frame.size.width-276, 11, 100, 22)];
+    UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.tableView.frame.size.width-300, 11, 100, 22)];
     pricelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
     pricelabel.textColor=UIColorFromRGB(color);
     pricelabel.backgroundColor = [UIColor clearColor];
@@ -494,7 +494,7 @@
     [pricelabel sizeToFit];
     [myView addSubview:pricelabel];
     
-    UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.tableView.frame.size.width-163/*605*/,11, 148, 22)];
+    UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.tableView.frame.size.width-113/*605*/,11, 148, 22)];
     timelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
     timelabel.textColor=UIColorFromRGB(color);
     timelabel.backgroundColor = [UIColor clearColor];
@@ -672,13 +672,37 @@
         NSDictionary * item_json = self.table_data[indexPath.row];
         
         cell.labelAgent.text = item_json[@"agent_name"];
-        NSString* sss =item_json[@"doc_number"];
+        NSString* job_addr =item_json[@"job_addr"];
+        NSString* job_city =item_json[@"job_city"];
+        NSString* job_state =item_json[@"job_state"];
+        NSString* job_zip =item_json[@"job_zip"];
+        NSString* tel =item_json[@"tel"];
+        
+        if(tel.length>0)
+            tel= [@"TEL: " stringByAppendingString:tel];
+        
+        
+        NSMutableArray* arr_ext= [[NSMutableArray alloc] init];
+        
+        [arr_ext addObject:job_addr];
+        [arr_ext addObject:@"\r\n"];
+        
+        [arr_ext addObject:job_city];
+        [arr_ext addObject:job_state];
+        [arr_ext addObject:job_zip];
+        [arr_ext addObject:@"\r\n"];
+        [arr_ext addObject:tel];
+        
+        NSString *nsext=[RAUtils arr2string:arr_ext separator:@", " trim:true];
+        
+        
+        nsext=[nsext stringByReplacingOccurrencesOfString:@", \r\n," withString:@"\r\n"];
         
         
         //    if(sss.length==0)
         //        sss=@"";
         cell.labelDocID.text = item_json[@"doc_number"];//
-        cell.labelExtInfo.text =item_json[@"address"];
+        cell.labelExtInfo.text =nsext;
         cell.labelJobDate.text =item_json[@"job_date"];
         cell.labelCustomer.text =item_json[@"customer_name"];
         cell.labelSignDate.text =item_json[@"signed_date"];

+ 163 - 0
Ants Contract/common/DocumentPageViewController.m

@@ -20,7 +20,9 @@
 #import "PDFViewController.h"
 #import "config.h"
 #import "AESCrypt.h"
+#import "CustomIOSAlertView.h"
 
+#import "ImageUtils.h"
 
 
 @interface DocumentPageViewController ()
@@ -152,6 +154,7 @@
             
             
         };
+        
         //    orderinfoVC.url_type = URL_REMOTE;
         //    orderinfoVC.request_url=URL_CARTDELIVERY;
         //
@@ -168,6 +171,28 @@
         
         
         
+    };
+    
+    signatureVC.blk_Fill =^(NSString* file)
+    {
+        
+        
+        
+        //            NSString* file_name=[file lastPathComponent];
+//        
+//        NSData* img_data=[ImageUtils load_img:file];
+//        
+//        if(img_data!=nil)
+//        {
+//            
+//            UIImage* image=[UIImage imageWithData:img_data];
+//            touchImageView.image = image;
+//            
+//            long index = touchImageView.tag - CONTROL_BASE;
+//            self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value"] = file;
+//            
+//        }
+        
     };
     
     UINavigationController * navi = [[UINavigationController alloc] initWithRootViewController:signatureVC];
@@ -208,6 +233,10 @@
 }
 - (IBAction)onSaveClicked:(id)sender {
     
+    if([self verifyData]==false)
+        return;
+    
+    
     __weak typeof(self) weakSelf = self;
     NSString* pdffile = [PDFUtils SavePDF:self.controlTemplate source:self.document window_rect:CGRectMake(0, 0, 768, 960)];
     
@@ -477,6 +506,140 @@
     return viewController.pageIndex;//[self.pagePDF indexOfObject:viewController.pdfview];
 }
 
+#pragma mark verify data
+- (UIView *)createDemoView:(NSString*) msg
+{
+    UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 290, 200)];
+    
+    //    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 270, 180)];
+    //    [imageView setImage:[UIImage imageNamed:@"demo"]];
+    
+    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 270, 10)];
+    titleLabel.font = [UIFont boldSystemFontOfSize:20];
+    titleLabel.text=@"Please complete missing fields:";
+    titleLabel.numberOfLines = 0;
+    titleLabel.lineBreakMode =NSLineBreakByWordWrapping;
+    //    titleLabel.textAlignment = NSTextAlignmentRight;
+    titleLabel.textAlignment = NSTextAlignmentCenter;
+    CGSize constraintkey = CGSizeMake(270, 20000.0f);//key label width is 40% cell width;
+    CGSize sizetitle = [@"Please complete missing fields:" sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
+    
+    //[titleLabel sizeToFit];
+    //    titleLabel.center.x = demoView.center.x;
+    titleLabel.frame = CGRectMake(10, 10, 270, sizetitle.height);
+    [demoView addSubview:titleLabel];
+    
+    UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, 10)];
+    lineLabel.font = [UIFont boldSystemFontOfSize:17];
+    lineLabel.text=msg;
+    lineLabel.numberOfLines = 0;
+    lineLabel.lineBreakMode =NSLineBreakByWordWrapping;
+    
+    CGSize sizemsg = [msg sizeWithFont:[UIFont boldSystemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
+    
+    lineLabel.frame = CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, sizemsg.height);
+    //[lineLabel sizeToFit];
+    
+    [demoView addSubview:lineLabel];
+    demoView.frame = CGRectMake(0, 0, 290, lineLabel.frame.origin.y+lineLabel.frame.size.height+25);
+    return demoView;
+}
+-(bool) verifyData
+{
+    return true;
+    bool ret=true;
+    int more=0;
+    NSMutableArray* fields=[[NSMutableArray alloc] init];
+    
+    for(int i=0;i<[self.controlTemplate[@"count"] intValue];i++)
+    {
+        NSMutableDictionary* page =self.controlTemplate[[NSString stringWithFormat:@"page_%d",i]];
+        for(int j=0;j<[page[@"count"] intValue];j++)
+        {
+            NSMutableDictionary* control =page[[NSString stringWithFormat:@"control_%d",j]];
+            NSString* type = control[@"type"];
+            NSString* name = control[@"aname"];
+            bool required = [control[@"required"] boolValue];
+            
+            if(required==false)
+                continue;
+            if([type isEqualToString:@"Check"])
+            {
+                NSArray* arr = control[@"value"];
+                if(arr.count==0)
+                {
+                    ret=false;
+                    
+                    NSString* msg=[NSString stringWithFormat:@"%u Page %d %@ is missing.",fields.count+1,i+1,name];
+                    if(fields.count<15)
+                        [fields addObject:msg];
+                    else
+                        more++;
+                }
+                
+            }
+            else if(/*[type isEqualToString:@"Signature"]||*/[type isEqualToString:@"Image"]||[type isEqualToString:@"Label"])
+            {
+                continue;
+            }
+            else
+            {
+                NSString* str = control[@"value"];
+                if(str.length==0)
+                {
+                    ret=false;
+                    NSString* msg=[NSString stringWithFormat:@"%u Page %d %@ is missing.",fields.count+1,i+1,name];
+                    if(fields.count<15)
+                        [fields addObject:msg];
+                    else
+                        more++;
+                }
+            }
+        }
+    }
+    if(ret==false)
+    {
+        if(more>0)
+        {
+            NSString* msg=[NSString stringWithFormat:@"And %d more missing field.",more];
+            [fields addObject:@"......"];
+                [fields addObject:msg];
+        }
+        NSString* missfields=[fields componentsJoinedByString:@"\n"];
+        NSString* msg = [NSString stringWithFormat:@"%@",missfields];
+        
+        CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init];
+        
+        
+        
+        
+        // Add some custom content to the alert view
+        [alertView setContainerView:[self createDemoView:msg]];
+        
+        // Modify the parameters
+        
+        
+        
+        [alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"OK", nil]];
+        //[alertView setDelegate:self];
+        
+        // You may use a Block, rather than a delegate.
+        [alertView setOnButtonTouchUpInside:^(CustomIOSAlertView *alertView, int buttonIndex) {
+            //   DebugLog(@"Block: Button at position %d is clicked on alertView %d.", buttonIndex, (int)[alertView tag]);
+            [alertView close];
+        }];
+        
+        //  [alertView setUseMotionEffects:true];
+        
+        // And launch the dialog
+        
+        [alertView sizeToFit];
+        [alertView show];
+        
+        
+    }
+    return ret;
+}
 
 #pragma mark - Page View Controller Data Source
 

+ 311 - 4
Ants Contract/common/PageViewController.m

@@ -15,7 +15,11 @@
 #import "SignatureViewController.h"
 #import "PDFUtils.h"
 #import "ImageUtils.h"
+#import "TextUtils.h"
+
 #import "CheckSelectorViewController.h"
+#import "DatePickerViewController.h"
+
 
 
 //#import "TouchImageView.h"
@@ -97,10 +101,38 @@
             [self addLabel:control destView:self.editControlView index:i];
             
         }
+        else if([control[@"type"] isEqualToString:@"DatePicker"])
+        {
+            [self addDatePicker:control destView:self.editControlView index:i];
+            
+        }
     }
     
 }
 #pragma mark add controls
+-(bool) checkActionCondition:(NSString*) condition
+{
+    if([condition isEqualToString:@"true"])
+        return true;
+    if([condition isEqualToString:@"control_18:[value]==0"])
+    {
+        NSArray* arr= self.controlTemplate[@"control_18"][@"value"];
+        if(arr.count==0)
+            return false;
+        else
+            return [arr[0] intValue]==0;
+
+    }
+    
+    return false;
+}
+-(UIView*) findControl:(NSString*)controlName
+{
+
+    controlName=[controlName stringByReplacingOccurrencesOfString:@"control_" withString:@""];
+    int d_idx = [controlName intValue];
+    return [self.view viewWithTag:d_idx+CONTROL_BASE];
+}
 -(void) addTextView:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
 {
     UITextView* tv = [[UITextView alloc] initWithFrame:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue])];
@@ -108,7 +140,9 @@
     if(fontsize==0)
         fontsize=10;
     [tv setFont:[UIFont systemFontOfSize:fontsize]];
+    bool isdisable = [template[@"disable"] boolValue];
     
+    tv.editable = !isdisable;
     tv.text =template[@"value"];
     
     tv.tag = index+ CONTROL_BASE;
@@ -183,6 +217,29 @@
     }
     [destView addSubview:btn];
 }
+-(void) addDatePicker:(NSMutableDictionary*) template destView:(UIView*)destView index:(int) index
+{
+    UIButton* btn = [[UIButton alloc] initWithFrame:CGRectMake([template[@"pos_x"] floatValue], [template[@"pos_y"] floatValue], [template[@"width"] floatValue], [template[@"height"] floatValue])];
+    
+
+    [btn setTitle:template[@"value"] forState:UIControlStateNormal];
+    float fontsize = [template[@"size"] floatValue];
+    if(fontsize==0)
+        fontsize=10;
+    btn.titleLabel.font = [UIFont systemFontOfSize: fontsize];
+    btn.tag = index+ CONTROL_BASE;
+    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+    //    ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged
+    btn.backgroundColor = UIColorFromRGB(BT_BG);
+    [btn addTarget:self action:@selector(ControlDatePickerClicked:) forControlEvents:UIControlEventTouchUpInside];
+    if(DEBUG_PDFSIG)
+    {
+        // btn.backgroundColor = [UIColor lightGrayColor];
+        
+        // [btn setBackgroundImage:[UIColor grayColor] forState:UIControlStateNormal];
+    }
+    [destView addSubview:btn];
+}
 -(UIView*) createMarker:(int)size x:(int)x y:(int)y
 {
     UIView* v=[[UIView alloc] initWithFrame:CGRectMake(x, y, size, size)];
@@ -210,7 +267,9 @@
     NSArray* cadedate = template[@"cadedate"];
     
     NSArray* checkedData = self.controlTemplate [[NSString stringWithFormat:@"control_%d",index] ][@"value"];
-
+    float fontsize = [template[@"size"] floatValue];
+    if(fontsize==0)
+        fontsize=10;
 
 //    if(checkedData.count>0)
 //        marker_bg = [UIColor clearColor];
@@ -220,7 +279,23 @@
     for(int i=0;i<cadedate.count;i++)
     {
         NSArray* item = cadedate[i];
-        
+        NSArray* checkmarker = item[1];
+        if(checkmarker.count==0)
+        {
+            [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+            btn.titleLabel.font = [UIFont systemFontOfSize: fontsize];
+            btn.backgroundColor = UIColorFromRGB(CK_BG);
+            if([checkedData containsObject:[NSNumber numberWithLong:i]])
+            {
+                [btn setTitle:item[0][0] forState:UIControlStateNormal];
+                
+            }
+            continue;
+        }
+        else
+        {
+            [btn setTitle:@"" forState:UIControlStateNormal];
+        }
         UIView* marker=[self createMarker:[template[@"marker_size"] intValue] x:[item[1][0] intValue] y:[item[1][1] intValue]];
         
         marker.backgroundColor = marker_bg;
@@ -324,6 +399,43 @@
 //
 //}
 #pragma mark Button Click
+- (void)ControlDatePickerClicked:(UIButton *)sender {
+    
+    
+        long index = sender.tag - CONTROL_BASE;
+    
+    __weak __typeof(self)weakSelf = self;
+    NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
+    [formatter setDateFormat:@"MM/dd/yyyy"];
+    NSString* date = @"";
+    
+    NSDate* currentDate =nil;
+    if(date.length==0)
+        currentDate=[NSDate date];
+    else
+        currentDate=[formatter dateFromString:date];
+    
+    DatePickerViewController* dpvc =[ [UIStoryboard storyboardWithName:@"CommonEditor" bundle:nil] instantiateViewControllerWithIdentifier:@"DatePickerViewController"];
+    
+    dpvc.pickerMode = UIDatePickerModeDate;
+    
+    
+    
+    dpvc.date = currentDate;
+    dpvc.formatter = formatter;
+    dpvc.labelTime.text = [formatter stringFromDate:currentDate];
+    
+    dpvc.blk_Set = ^(NSString* strdate)
+    {
+//        weakSelf.labelSignDate.text = strdate;
+        
+        [sender setTitle:strdate forState:UIControlStateNormal];
+        
+           weakSelf.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value"] = strdate;
+    };
+    dpvc.title=@"Please choose a date";
+    [self.navigationController pushViewController:dpvc animated:true];
+}
 - (void)ControlButtonClicked:(UIButton *)sender {
     //    DebugLog(@"cart sort button clicked");
     
@@ -345,9 +457,86 @@
     CheckSelectorViewController *checkVC = [ [UIStoryboard storyboardWithName:@"signature" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"CheckSelectorViewController"];
     
     checkVC.blk_OK = ^(NSArray* checkedData){
+        
+        
+
+        
         for(int i=0;i<rowData.count;i++)
         {
             long tag=CHECK_BASE+index*1000+i;
+            
+            
+            
+            NSArray* item = rowData[i];
+            NSArray* checkmarker = item[1];
+            if(checkmarker.count==0)
+            {
+                sender.backgroundColor = UIColorFromRGB(CK_BG);
+                if([checkedData containsObject:[NSNumber numberWithLong:i]])
+                {
+                    [sender setTitle:item[0][0] forState:UIControlStateNormal];
+                    if(item.count>=3)
+                    {
+                        NSMutableDictionary* action = item[2];
+                        NSArray* disable_arr = action[@"disable"] ;
+                        for(int d = 0 ; d<disable_arr.count;d++)
+                        {
+                            self.controlTemplate [disable_arr[d] ] [@"disable"] = [NSNumber numberWithBool:true];
+                            NSString* s_idx =disable_arr[d];
+                            s_idx=[s_idx stringByReplacingOccurrencesOfString:@"control_" withString:@""];
+                            int d_idx = [s_idx intValue];
+                            ((UITextView*)[sender.superview viewWithTag:d_idx+CONTROL_BASE]).editable = false;
+                        }
+                        NSArray* enable_arr = action[@"enable"] ;
+                        for(int e = 0 ; e<enable_arr.count;e++)
+                        {
+                            self.controlTemplate [enable_arr[e] ] [@"disable"] = [NSNumber numberWithBool:false];
+                            
+                            NSString* s_idx =enable_arr[e];
+                            s_idx=[s_idx stringByReplacingOccurrencesOfString:@"control_" withString:@""];
+                            int d_idx = [s_idx intValue];
+
+                            ((UITextView*)[sender.superview viewWithTag:d_idx+CONTROL_BASE]).editable = true;
+                        }
+                        
+                        NSMutableDictionary* json_setval=action[@"set_val"] ;
+                        for(int i=0;i<[json_setval[@"count"] intValue];i++)
+                        {
+                            
+                            NSMutableDictionary * control =  json_setval [[NSString stringWithFormat:@"item_%d",i] ];
+                            UITextView* tv = (UITextView*) [self findControl:control[@"control"]];
+                            NSString* value = control[@"value"];
+                            
+                            UITextView* tv6 = (UITextView*) [self findControl:@"control_6"];
+                            NSString* text = tv6.text;
+                            NSString* newvalue = nil;
+                            if([value isEqualToString:@"*0.1"])
+                            {
+                                float f= [[text stringByReplacingOccurrencesOfString:@"$" withString:@"" ] floatValue]*0.1;
+                                newvalue = [NSString stringWithFormat:@"$ %.2f",f];
+                                self.controlTemplate [control[@"control"] ][@"value"] = newvalue;
+                            }
+                            else if([value isEqualToString:@"*0.9"])
+                            {
+                                float f= [[text stringByReplacingOccurrencesOfString:@"$" withString:@"" ] floatValue]*0.9;
+                                newvalue = [NSString stringWithFormat:@"$ %.2f",f];
+                                self.controlTemplate [control[@"control"] ][@"value"] = newvalue;
+                            }
+
+                            
+                            tv.text = newvalue;
+                            
+                        }
+                    }
+                    
+                }
+                continue;
+            }
+            else
+            {
+                [sender setTitle:@"" forState:UIControlStateNormal];
+            }
+            
            // UIView* v= sender;
             if([checkedData containsObject:[NSNumber numberWithLong:i]])
             {
@@ -361,9 +550,10 @@
                // [self.checkedData addObject:[NSNumber numberWithLong:indexPath.row] ];
                 [sender.superview viewWithTag:tag].backgroundColor= [UIColor clearColor];
             }
-            self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value"]=checkedData;
+            
             
         }
+        self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value"]=checkedData;
     };
     checkVC.rowData = rowData;
     checkVC.checkedData = [checkedData mutableCopy];
@@ -377,16 +567,112 @@
 }
 
 #pragma mark TextViewDelegate
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
+{
+    
+    
+    long index = textView.tag - CONTROL_BASE;
+    
+    NSString* oldtext =textView.text;
+    if(oldtext==nil)
+        oldtext=@"";
+
+    bool canChange=true;
+    
+    int max_line = [self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"lines"] intValue];
+    if(max_line==0)//默认只能有一行
+        max_line=1;
+    long linecount=[TextUtils countOccurencesOfString:oldtext find:@"\n"];
+    if(max_line!=-1) //maxline -1表示不限制行数。
+    {
+        if(linecount<=max_line-1&& [text isEqualToString:@"\n"])
+        {
+            canChange = false;
+        }
+    }
+
+    int lenth = [self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"length"] intValue];
+    if(lenth==0)
+        return canChange;
+    else
+    {
+        return canChange&& (lenth>textView.text.length ||[text isEqualToString:@""]);
+    }
+
+}
 - (void)textViewDidEndEditing:(UITextView *)textView
 {
     
     long index = textView.tag - CONTROL_BASE;
     
-    NSString* text =textView.text;
+    
+    //处理 prefix 和 浮点格式化
+        NSString* prefix_str= self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"prefix_str"];
+    if(prefix_str.length==0)
+        prefix_str = @"";
+    NSString* text = [textView.text stringByReplacingOccurrencesOfString:prefix_str withString:@""];
+    
+    NSString* value_type= self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value_type"];
+    if([value_type isEqualToString:@"float"])
+        text=[NSString stringWithFormat:@"%.2f",[text floatValue] ];
+    
+
+
+    text =[NSString stringWithFormat:@"%@%@",prefix_str,text] ;
+    
+    textView.text = text;
+    
     if(text==nil)
         text=@"";
     self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value"] = text;
     
+    NSDictionary* action = self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"action"];
+    NSArray* keys=[action allKeys];
+    for(int k=0;k<keys.count;k++)
+    {
+        NSMutableDictionary* act_k = action[keys[k] ];
+        
+        
+        if (![self checkActionCondition:act_k[@"condition"]])
+            continue;
+        for(int i=0;i<[act_k[@"count"] intValue];i++)
+        {
+            
+            NSMutableDictionary * control =  act_k [[NSString stringWithFormat:@"item_%d",i] ];
+            UITextView* tv = (UITextView*) [self findControl:control[@"control"]];
+            NSString* value = control[@"value"];
+            
+            NSString* newvalue = nil;
+            if([value isEqualToString:@"*0.1"])
+            {
+                float f= [[text stringByReplacingOccurrencesOfString:@"$" withString:@"" ] floatValue]*0.1;
+                newvalue = [NSString stringWithFormat:@"$ %.2f",f];
+                
+                self.controlTemplate [control[@"control"] ][@"value"] = newvalue;
+            }
+            else if([value isEqualToString:@"*0.9"])
+            {
+                float f= [[text stringByReplacingOccurrencesOfString:@"$" withString:@"" ] floatValue]*0.9;
+                newvalue = [NSString stringWithFormat:@"$ %.2f",f];
+                self.controlTemplate [control[@"control"] ][@"value"] = newvalue;
+            }
+            else if([value isEqualToString:@"control_6-control_7"])
+            {
+                
+                UITextView* tv6 = (UITextView*) [self findControl:@"control_6"];
+                float f6= [[tv6.text stringByReplacingOccurrencesOfString:@"$" withString:@"" ] floatValue];
+                
+                float f7= [[text stringByReplacingOccurrencesOfString:@"$" withString:@"" ] floatValue];
+                newvalue = [NSString stringWithFormat:@"$ %.2f",f6-f7];
+                self.controlTemplate [control[@"control"] ][@"value"] = newvalue;
+            }
+            
+            tv.text = newvalue;
+            
+        }
+    }
+
+    
 //    int count = [self.controlTemplate[@"count"] intValue];
 //    for(int i=0;i<count;i++)
 //    {
@@ -444,6 +730,27 @@
                 
             }
 
+        };
+        signatureVC.blk_Fill =^(NSString* file)
+        {
+            
+            
+            
+//            //            NSString* file_name=[file lastPathComponent];
+//            
+//            NSData* img_data=[ImageUtils load_img:file];
+//            
+//            if(img_data!=nil)
+//            {
+//                
+//                UIImage* image=[UIImage imageWithData:img_data];
+//                touchImageView.image = image;
+//                
+//                long index = touchImageView.tag - CONTROL_BASE;
+//                self.controlTemplate [[NSString stringWithFormat:@"control_%ld",index] ][@"value"] = file;
+//                
+//            }
+            
         };
         signatureVC.blk_Add = ^()
         {

+ 1 - 0
Ants Contract/common/SignatureListViewController.h

@@ -17,4 +17,5 @@
 //@property (strong, nonatomic)  UIImageView *imageView;
 @property (nonatomic , copy) void (^blk_Add)();
 @property (nonatomic , copy) void (^blk_Select)(NSString* file);
+@property (nonatomic , copy) void (^blk_Fill)(NSString* file);
 @end

+ 14 - 0
Ants Contract/common/SignatureListViewController.m

@@ -37,6 +37,20 @@
     
 
     
+}
+- (IBAction)onFillClick:(id)sender {
+    
+    UITableViewCell* cell = ((UIView*)sender).superview.superview;
+    
+        NSIndexPath *   indexPath = [self.tableView indexPathForCell:cell];
+    
+    
+    NSDictionary * item_json = self.signatureData[[NSString stringWithFormat:@"item_%ld",(long)indexPath.section]];
+    
+    //        UIImage* img = [UIImage imageWithContentsOfFile:item_json[@"file"]];
+    
+    if(self.blk_Fill)
+        self.blk_Fill(item_json[@"file"]);
 }
 
 /*