Răsfoiți Sursa

161027
Modify:
create portfolio

Ray Zhang 9 ani în urmă
părinte
comite
f019686d92

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/UserInterfaceState.xcuserstate


Fișier diff suprimat deoarece este prea mare
+ 5 - 1037
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist


+ 2 - 0
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.h

@@ -36,6 +36,8 @@
 //@property (strong,nonatomic) NSString* data_url;
 //@property bool data_separate;
 @property (strong,nonatomic) NSMutableDictionary* params;
+@property (strong,nonatomic) NSString* item_ids;
+@property (strong,nonatomic) NSString* product_ids;
 @property (strong, nonatomic) IBOutlet UITableView *editorTable;
 
 @property (nonatomic, weak) id<CommonEditorViewControllerDelegate> delegate;

+ 155 - 6
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -25,13 +25,58 @@
 
 @implementation OLDataProvider
 
-+(NSString*) create_portfolio
+
+
++ (NSString *)portfolio_img:(NSString *)item_id db:(sqlite3 *)db
 {
-    // not impl
-    return nil;
+    
+    NSString* ret= nil;
+    
+    NSString *sqlQuery = nil;
+    
+    //    sqlQuery = [NSString stringWithFormat:@"select i.url from product m LEFT join model_image i on m.product_id = i.product_id  where m.item_id=%@ order by i.default_img desc, i._id asc limit 1;",item_id];// select i.url from model m
+    sqlQuery = [NSString stringWithFormat:@"select i.url from model_image as i where item_id = %@ and i.type<=1 order by i.default_img desc, i.type desc limit 1;",item_id];
+    sqlite3_stmt * statement;
+    
+    //    int count=0;
+    if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
+    {
+        
+        
+        if (sqlite3_step(statement) == SQLITE_ROW)
+        {
+            
+            
+            char *imgurl = (char*)sqlite3_column_text(statement, 0);
+            if(imgurl==nil)
+            imgurl="";
+            NSString *nsimgurl = [[NSString alloc]initWithUTF8String:imgurl];
+            
+            
+            ret=nsimgurl;
+            
+            
+        }
+        
+        sqlite3_finalize(statement);
+    }
+    else
+    {
+        [ret setValue:@"8" forKey:@"result"];
+    }
+    
+    
+    
+    //  [iSalesDB close_db:db];
+    //    DebugLog(@"data string: %@",ret );
+    
+    
+    return ret;
+    
 }
 +(NSMutableDictionary*) prepare_portfolio_data:(NSMutableDictionary*) params
 {
+    //生成portfolio pdf需要的数据
     NSMutableDictionary* data = [[NSMutableDictionary alloc]init];
     data[@"npd_url"]=@"www.newpacificdirect.com";
     NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
@@ -40,9 +85,112 @@
     data[@"create_month"]=date;
     data[@"company_name"]=@"New Pacific Direct,Inc.";
     data[@"catalog_name"]=params[@"catalog_name"];
-//    NSMutableDictionary* header = [[NSMutableDictionary alloc]init];
-//    header[@"icon_small"]=@"portfolio_logo_s";
-//    data[@"header"]=header;
+    data[@"PAGE_INDEX"]=@"Page $.{CURRENT_PAGE}.$ of $.{TOTAL_PAGE}.$";
+    data[@"TOTAL_PAGE"]=0;
+    data[@"CURRENT_PAGE"]=0;
+    NSMutableDictionary* grid = [[NSMutableDictionary alloc]init];
+    
+    
+    
+    NSString *sql = [NSString stringWithFormat:@"select a.product_id,a.name,a.description,a.price,a.sheet_discount,a.qty,a.percentage,a.item_id,a.fashion_id,a.line_note,a.percent,a._id from (select _id, product_id,name,description,ifnull(sheet_price,'null') as price,sheet_discount,ifnull(available_qty,'null') as qty,percentage,item_id,fashion_id,line_note,percent from offline_portfolio where product_id in(%@)) a left join (select * from product where product_id in(%@)) b on a.product_id=b.product_id",params[@"product_ids"],params[@"product_ids"]];
+    
+    __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
+    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    
+    sqlite3 *db = [iSalesDB get_db];
+    NSDictionary *resultDic = [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
+        
+     //   [dic setValue:[NSNumber numberWithInteger:RESULT_TRUE] forKey:@"result"];
+        
+        int product_id = sqlite3_column_int(stmt, 0);
+        NSString *product_id_string = [NSString stringWithFormat:@"%d",product_id];
+        NSString *name = [self textAtColumn:1 statement:stmt];
+        NSString *description = [self textAtColumn:2 statement:stmt];
+        double price = sqlite3_column_double(stmt, 3);
+        double discount = sqlite3_column_double(stmt,4);
+        int qty = sqlite3_column_int(stmt, 5);
+        int percentage = sqlite3_column_int(stmt, 6);
+        int item_id = sqlite3_column_int(stmt, 7);
+        //        int fashion_id = sqlite3_column_int(stmt, 8);
+        NSString *line_note = [self textAtColumn:9 statement:stmt];
+        double percent = sqlite3_column_double(stmt, 10);
+        int portfolio_id = sqlite3_column_int(stmt, 11);
+        NSString* img_path = [self portfolio_img:[NSString stringWithFormat:@"%@",[NSNumber numberWithInt:item_id]] db:db];
+        
+        
+        NSString* set_price=@"";
+        NSString *price_null = [self textAtColumn:3 statement:stmt];
+        if ([price_null isEqualToString:@"null"]) {
+
+        }
+        else
+        {
+            set_price=[NSString stringWithFormat:@"%.2f",price*(1-discount)];
+        }
+        NSString* get_price=@"";
+        {
+            NSNumber* price = [self get_model_default_price:appDelegate.contact_id product_id:nil item_id:@(item_id) db:db];
+            //                DebugLog(@"price time interval");
+            //                [self printTimeIntervalBetween:price_date and:[NSDate date]];
+            
+            if(price!=nil)
+                get_price=[NSString stringWithFormat:@"%.2f",price.floatValue];
+        }
+        
+        
+
+        
+        
+        NSMutableDictionary *item = @{
+                                      @"linenotes": line_note,
+//                                      @"product_id": product_id_string,
+//                                      @"available_qty": @(qty),
+//                                      @"available_percent" : @(percent),
+//                                      @"description": [NSString stringWithFormat:@"%@\n%@",name,description],
+//                                      @"item_id": [NSString stringWithFormat:@"%d",item_id],
+//                                      @"fashion_id": [NSString stringWithFormat:@"%d",product_id],
+                                      @"img": img_path,
+                                      @"img_qr": img_path,
+                                      @"special_price": set_price,
+                                      @"price": get_price,
+                                      @"name": get_price,
+                                      @"description": get_price,
+                                      @"detail": get_price
+                                      }.mutableCopy;
+        if (percentage) {
+            [item removeObjectForKey:@"available_qty"];
+        } else {
+            [item removeObjectForKey:@"available_percent"];
+        }
+        
+        NSString *qty_null = [self textAtColumn:5 statement:stmt];
+        if ([qty_null isEqualToString:@"null"]) {
+            [item removeObjectForKey:@"available_qty"];
+        }
+        
+        
+        [dic setObject:item forKey:[NSString stringWithFormat:@"item_%ld",*count]];
+        [dic setValue:[NSNumber numberWithLong:++(*count)] forKey:@"count"];
+        
+    }];
+    
+
+    [iSalesDB close_db:db];
+    
+    
+    
+//    [dic setValue:[NSNumber numberWithBool:appDelegate.can_see_price] forKey:@"can_see_price"];
+//    [dic setValue:@"" forKey:@"email_content"];
+//    [dic setValue:[dic objectForKey:@"count"] forKey:@"total_count"];
+//    [dic setValue:@"Regular Mode" forKey:@"mode"];
+//    
+    
+    
+//    NSMutableDictionary* cell = [[NSMutableDictionary alloc]init];
+//    cell[@"count"]=[NSNumber numberWithInt:10];
+    grid[@"cell0"]=dic;
+    data[@"grid0"]=grid;
     return data;
 }
 +(NSMutableDictionary*) get_pdftemplate:(NSString*) template
@@ -3698,6 +3846,7 @@
     
     
 }
+
 +(NSDictionary*) model_img :(int)product_id db:(sqlite3*)db
 {
     NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];

+ 2 - 0
RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m

@@ -387,6 +387,8 @@
     VC.request_url=URL_DM_PARAMS;
     
     VC.params = params;
+    VC.product_ids=string;
+    VC.item_ids=string_iid;
     
     //    VC.delegate=self;
     

+ 2 - 1
RedAnt ERP Mobile/common/Functions/portfolio/TearSheetParamViewController.m

@@ -269,7 +269,8 @@
     
     upparams[@"pdfUrl"]=pdf_url;
     
-    
+    upparams[@"product_ids"]=self.product_ids;
+    upparams[@"item_ids"]=self.item_ids;
     
     //   pdf_url=[pdf_url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     

+ 1 - 1
RedAnt ERP Mobile/common/RAUtils.h

@@ -40,7 +40,7 @@ typedef void (^add_to_cart_Handler)(void);
 + (NSArray*) allFilesAtPath:(NSString*) dirString;
 +(void) enum_font;
 +(NSDictionary*) dictfromfile:(NSString*) path;
-
++(NSArray*) expression_varable:(NSString*)content regex:(NSString*) pattern;
 +(NSData*) getdbfile;
 +(NSString*) getdbzip;
 + (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size;

+ 24 - 1
RedAnt ERP Mobile/common/RAUtils.m

@@ -160,6 +160,25 @@
         }
     }
 }
++(NSArray*) expression_varable:(NSString*)content regex:(NSString*) pattern
+{
+    
+    
+
+    
+    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:nil error:nil];
+    
+    NSArray *matches = [regex matchesInString:content options:nil range:NSMakeRange(0, content.length)];
+    
+    if (matches) {
+        for (NSTextCheckingResult *match in matches) {
+            for (int i = 0; i < match.numberOfRanges; ++i) {
+                NSLog(@"-> %@", [content substringWithRange:[match rangeAtIndex:i]]);
+            }
+        }  
+    }
+    return matches;
+}
 + (CGRect)rectAlign:(CGRect )parent rect:(CGRect)rect hAlign:(NSString*)hAlign vAlign:(NSString*)vAlign
 {
 //    double cx=parent.origin.x+parent.size.width/2;
@@ -169,7 +188,11 @@
     {
         rect=CGRectMake(centerpoint.x-rect.size.width/2, rect.origin.y, rect.size.width, rect.size.height);
     }
-    
+    else
+    if([hAlign.lowercaseString isEqualToString:@"left"])
+    {
+        rect=CGRectMake(parent.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+    }
     if([vAlign.lowercaseString isEqualToString:@"middle"])
     {
         rect=CGRectMake(rect.origin.x, centerpoint.y-rect.size.height/2, rect.size.width, rect.size.height);

+ 3 - 3
RedAnt ERP Mobile/common/pdfCreator/GridDrawable.m

@@ -108,7 +108,7 @@
     drawable_obj.delegate = self.delegate;
     NSMutableDictionary* rows_data = table_data[celljson[@"data_source"]];
     int row_data_count=[rows_data[@"count"] intValue];
-    float dy=0;
+    float dy=y;
     float dx=0;
     for(int j=0;j<row_data_count;j++)
     {
@@ -129,7 +129,7 @@
             //越界,新起一页
             if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {
                 [self.delegate outofPage:context];
-                dy=0;
+                dy=y;
                 dx=0;
             }
         }
@@ -152,7 +152,7 @@
             dy+=row_rect.size.height;
             if(dy+row_rect.size.height>parentrect.size.height)
             {
-                dy=0;
+                dy=y;
                 dx+=row_rect.size.width;
             }
 

+ 2 - 1
RedAnt ERP Mobile/common/pdfCreator/GroupDrawable.m

@@ -62,7 +62,8 @@
         drawable_obj.delegate=self.delegate;
         [drawable_obj Draw:context dataSource:data ParentRect:(CGRect)pdfrect startX:0 startY:0 flipHeight:flip_height range:between_header_and_footer];
     }
-    
+    [self DrawBound:context dataSource:data ParentRect:p_rect startX:x startY:y flipHeight:flip_height range:between_header_and_footer];
+
     return parentrect;
 //    return CGPointMake(parentrect.origin.x+parentrect.size.width, parentrect.origin.y+parentrect.size.height);    
 //    if (self.delegate && [self.delegate respondsToSelector:@selector(outofPage:)]) {

+ 30 - 3
RedAnt ERP Mobile/common/pdfCreator/ImageDrawable.m

@@ -8,8 +8,21 @@
 
 #import "ImageDrawable.h"
 #import "RAUtils.h"
+#import "iSalesDB.h"
 
 @implementation ImageDrawable
+
+-(void) setDrawableTemplate:(NSMutableDictionary *)drawableTemplate
+{
+    
+    [super setDrawableTemplate:drawableTemplate];
+    
+    
+    if(self.hAlign==nil)
+    self.hAlign=@"center";
+    if(self.vAlign==nil)
+    self.vAlign=@"middle";
+}
 -(CGRect) Query_Rect:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
 {
     CGRect parentrect = [self to_parent_rect:p_rect pos:self.rect offsetX:0 offsetY:0];
@@ -28,12 +41,26 @@
         image= [UIImage imageNamed:self.drawableTemplate[@"source"]];
         
     }
-    else
+    else if([source isEqualToString:@"data"])
+
     {
         
-        // not impl;
+        NSString* url=data[self.drawableTemplate[@"source"]];
         
-        image=[UIImage imageNamed:data[self.drawableTemplate[@"source"]]];
+        
+        NSString* file_name=[url lastPathComponent];
+        NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:url];
+        if(img_data!=nil)
+        {
+            
+            image=[UIImage imageWithData:img_data];
+            
+        }
+        else
+        {
+            image= [UIImage imageNamed:@"portfolio_img_404"];
+        }
+
     }
     
     

+ 2 - 2
RedAnt ERP Mobile/common/pdfCreator/LineDrawable.m

@@ -49,8 +49,8 @@
     
     
     CGPoint aPoints[2];//坐标点
-    aPoints[0] =[self to_pdf_point:p_rect point:CGPointMake([self.drawableTemplate[@"x0"] doubleValue], [self.drawableTemplate[@"y0"] doubleValue]) contextHeight:flip_height];//坐标1
-    aPoints[1] =[self to_pdf_point:p_rect point:CGPointMake([self.drawableTemplate[@"x1"] doubleValue], [self.drawableTemplate[@"y1"] doubleValue]) contextHeight:flip_height];//坐标2
+    aPoints[0] =[self to_pdf_point:p_rect point:CGPointMake([self.drawableTemplate[@"x0"] doubleValue]+x, [self.drawableTemplate[@"y0"] doubleValue]+y) contextHeight:flip_height];//坐标1
+    aPoints[1] =[self to_pdf_point:p_rect point:CGPointMake([self.drawableTemplate[@"x1"] doubleValue]+x, [self.drawableTemplate[@"y1"] doubleValue]+y) contextHeight:flip_height];//坐标2
     //CGContextAddLines(CGContextRef c, const CGPoint points[],size_t count)
     //points[]坐标数组,和count大小
     CGContextAddLines(context, aPoints, 2);//添加线

+ 1 - 0
RedAnt ERP Mobile/common/pdfCreator/PDFPage.h

@@ -24,6 +24,7 @@
 @property CGRect drawable_rect;
 @property double pos_x;
 @property double pos_y;
+@property double header_height;
 -(instancetype) init:(NSMutableDictionary *)page size:(CGRect)rect;
 -(void) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data;
 -(int) QueryPageCount:(CGContextRef) context dataSource:(NSMutableDictionary*)data;

+ 28 - 21
RedAnt ERP Mobile/common/pdfCreator/PDFPage.m

@@ -17,15 +17,15 @@
 @implementation PDFPage
 -(instancetype) init:(NSMutableDictionary *)page size:(CGRect)rect
 {
-   if (self = [super init]) {
-       self.rect = rect;
-       [self setPageTemplate:page];
-       self.pagecount=1;
-          }
-     return self;
+    if (self = [super init]) {
+        self.rect = rect;
+        [self setPageTemplate:page];
+        self.pagecount=1;
+    }
+    return self;
+    
     
     
-
 }
 -(void) setPageTemplate:(NSMutableDictionary *)pageTemplate
 {
@@ -43,7 +43,7 @@
     self.pos_x = _margin_left;
     self.pos_y = _margin_top;
     
-   // self.rect = CGRectMake(0, 0, [self.pageTemplate[@"width"] doubleValue], [self.pageTemplate[@"height"] doubleValue]);
+    // self.rect = CGRectMake(0, 0, [self.pageTemplate[@"width"] doubleValue], [self.pageTemplate[@"height"] doubleValue]);
 }
 -(int) QueryPageCount:(CGContextRef) context dataSource:(NSMutableDictionary*)data
 {
@@ -54,6 +54,8 @@
     self.data=data;
     GroupDrawable* pageHeader = [[GroupDrawable alloc]init:self.header];
     
+    
+    self.header_height=pageHeader.rect.size.height;
     pageHeader.delegate = self;
     GroupDrawable* pageFooter = [[GroupDrawable alloc]init:self.footer];
     
@@ -69,8 +71,8 @@
         
         CGRect rect = self.rect;
         
- //       CGContextBeginPage(context, &rect);
- //       [pageHeader Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
+        //       CGContextBeginPage(context, &rect);
+        //       [pageHeader Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
         
         
         for (int i=0;i<[self.pageTemplate[@"contents"][@"count"] intValue];i++)
@@ -108,11 +110,11 @@
                 
             }
             drawable_obj.delegate = self;
-            [drawable_obj Query_Rect:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:self.pos_x startY:_pos_y flipHeight:self.rect.size.height range:range];
+            [drawable_obj Query_Rect:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:self.header_height flipHeight:self.rect.size.height range:range];
         }
         
-    //    [pageFooter Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
-    //    CGContextEndPage(context);
+        //    [pageFooter Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
+        //    CGContextEndPage(context);
         
     }
     
@@ -125,8 +127,11 @@
     
     
     self.data=data;
-    GroupDrawable* pageHeader = [[GroupDrawable alloc]init:self.header];
     
+    
+    
+    GroupDrawable* pageHeader = [[GroupDrawable alloc]init:self.header];
+    self.header_height=pageHeader.rect.size.height;
     pageHeader.delegate = self;
     GroupDrawable* pageFooter = [[GroupDrawable alloc]init:self.footer];
     
@@ -135,11 +140,11 @@
     
     
     
-   // while (true)
+    // while (true)
     {
         // page 去除页眉,页脚后的区域
         NSRange range = NSMakeRange(self.drawable_rect.origin.y+pageHeader.rect.size.height, self.drawable_rect.origin.y+self.drawable_rect.size.height-pageFooter.rect.size.height);
-
+        
         CGRect rect = self.rect;
         
         CGContextBeginPage(context, &rect);
@@ -181,9 +186,9 @@
                 
             }
             drawable_obj.delegate = self;
-            [drawable_obj Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:self.pos_x startY:_pos_y flipHeight:self.rect.size.height range:range];
+            [drawable_obj Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:self.header_height flipHeight:self.rect.size.height range:range];
         }
-
+        
         [pageFooter Draw:context dataSource:data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
         CGContextEndPage(context);
         
@@ -196,16 +201,18 @@
     
     CGContextBeginPage(context, &rect);
     
-
+    
     
     GroupDrawable* pageHeader = [[GroupDrawable alloc]init:self.header];
     pageHeader.delegate = self;
     GroupDrawable* pageFooter = [[GroupDrawable alloc]init:self.footer];
     pageFooter.delegate = self;
     
+    self.data[@"CURRENT_PAGE"]=[NSNumber numberWithInt:[self.data[@"CURRENT_PAGE"] intValue]+1];
+    
     // page 去除页眉,页脚后的区域
     NSRange range = NSMakeRange(self.drawable_rect.origin.y+pageHeader.rect.size.height, self.drawable_rect.origin.y+self.drawable_rect.size.height-pageFooter.rect.size.height);
-
+    
     
     [pageHeader Draw:context dataSource:self.data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
     
@@ -214,7 +221,7 @@
     
     
     [pageFooter Draw:context dataSource:self.data ParentRect:(CGRect)self.drawable_rect startX:0 startY:0 flipHeight:self.rect.size.height range:range];
-   
+    
     
 }
 

+ 40 - 7
RedAnt ERP Mobile/common/pdfCreator/TextDrawable.m

@@ -20,15 +20,15 @@
 
     
     NSString* align= drawableTemplate[@"textAlignment"];
-    if(align.length==0 || [align isEqualToString:@"left"])
+    if(align.length==0 || [align.lowercaseString isEqualToString:@"left"])
     {
         self.textalignment= kCTTextAlignmentLeft;
     }
-    else if([align isEqualToString:@"right"])
+    else if([align.lowercaseString isEqualToString:@"right"])
     {
         self.textalignment= kCTTextAlignmentRight;
     }
-    else if([align isEqualToString:@"center"])
+    else if([align.lowercaseString isEqualToString:@"center"])
     {
         self.textalignment= kCTTextAlignmentCenter;
     }
@@ -119,6 +119,7 @@
     }
     return @"Helvetica";
 }
+
 -(CGRect) Draw:(CGContextRef) context dataSource:(NSMutableDictionary*)data ParentRect:(CGRect)p_rect startX:(double) x startY:(double) y flipHeight:(double)flip_height range:(NSRange)between_header_and_footer
 {
     
@@ -134,14 +135,46 @@
         self.text=self.drawableTemplate[@"text"];
         
     }
-    else
+    else if([source isEqualToString:@"data"])
     {
-        
-        // not impl;
-        
+        if([self.drawableTemplate[@"source_isexpression"] boolValue])
+        {
+            NSString *content =  data[self.drawableTemplate[@"source"]];
+            NSString *pattern = @"\\$\\.\\{([\\s\\S]*?)\\}\\.\\$";
+            NSArray* matches=[RAUtils expression_varable:content regex:pattern];
+//            if (matches) {
+//                for (NSTextCheckingResult *match in matches) {
+//                    for (int i = 0; i < match.numberOfRanges; ++i) {
+//                        NSLog(@"%d-> %@",i, [content substringWithRange:[match rangeAtIndex:i]]);
+//                    }
+//                }  
+//            }
+            if (matches)
+            {
+                self.text=content;
+                for (NSTextCheckingResult *match in matches)
+                {
+                    
+                    for (int i = 0; i < match.numberOfRanges/2; ++i) {
+                        NSLog(@"%d-> %@",i, [content substringWithRange:[match rangeAtIndex:i]]);
+                        NSLog(@"%d-> %@",i+1, [content substringWithRange:[match rangeAtIndex:i+1]]);
+                        
+                        self.text=[self.text stringByReplacingOccurrencesOfString:[content substringWithRange:[match rangeAtIndex:i]] withString:[NSString stringWithFormat:@"%@",data[[content substringWithRange:[match rangeAtIndex:i+1]]]]];
+                    }
+                }  
+            }
+            //self.text=content;
+            
+        }
+        else
+        {
         self.text=data[self.drawableTemplate[@"source"]];
+        }
     }
     
+    if(self.text==nil)
+        self.text=@"";
+    
     
     bool bold = [self.drawableTemplate[@"bold"] boolValue];
     bool italic = [self.drawableTemplate[@"italic"] boolValue];

+ 3 - 1
RedAnt ERP Mobile/common/pdfCreator/pdfCreator.m

@@ -139,13 +139,15 @@
     pdfContext=CGPDFContextCreateWithURL(url, &papersize, nil);
     
     
-    data[@"pages"][@"totalcount"]= [NSNumber numberWithInt:[self QueryTotalPage:pdfContext template:template dataSource:data]];
+    data[@"TOTAL_PAGE"]= [NSNumber numberWithInt:[self QueryTotalPage:pdfContext template:template dataSource:data]];
     
     NSMutableDictionary* pages=template[@"pages"];
     for(int i=0;i<[pages[@"count"] intValue];i++)
     {
         NSMutableDictionary* page=pages[[ NSString stringWithFormat:@"page_%d",i ] ];
         
+        data[@"CURRENT_PAGE"]=[NSNumber numberWithInt:[data[@"CURRENT_PAGE"] intValue]+1];
+        
         [self drawPage:pdfContext template:page size:papersize dataSource:data];
     }
     //开始画pdf

+ 1 - 1
RedAnt ERP Mobile/iSales-NPD/AppDelegate.m

@@ -758,7 +758,7 @@ void UncaughtExceptionHandler(NSException *exception) {
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
     
-  //  [RAUtils enum_font];
+//    [RAUtils expression_varable:nil regex:nil];
     self.disable_trigger = false;
     [self initialExceptionHandler];
     [self becomeObserver];

+ 21 - 0
RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_img_404.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "d-1@3x.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RedAnt ERP Mobile/iSales-NPD/pdfcreator.xcassets/portfolio_img_404.imageset/d-1@3x.png


+ 63 - 80
RedAnt ERP Mobile/iSales-NPD/portfolio_3x2.json

@@ -4,8 +4,8 @@
         "height": 612
     },
     "pages": {
-        "count": 2,
-        "page_0": {
+        "count": 1,
+        "page_1": {
             "name": "cover page",
             "header": {},
             "footer": {},
@@ -93,13 +93,13 @@
                 }
             }
         },
-        "page_1": {
+        "page_0": {
             "name": "content page",
             "header": {
                 "type": "group",
                 "x": 0,
                 "y": 0,
-                "width": 500,
+                "width": 752,
                 "height": 40,
                 "items": {
                     "count": 1,
@@ -116,28 +116,60 @@
                     }
                 }
             },
-            "footer": {},
-            "margin_left": 15,
-            "margin_right": 15,
-            "margin_top": 15,
-            "margin_bottom": 15,
+            "footer": {
+                "type": "group",
+                "x": 0,
+                "y": 571,
+                "width": 752,
+                "height": 21,
+                "items": {
+                    "count": 2,
+                    "item_0": {
+                        "type": "text",
+                        "source": "create_month",
+                        "source_type": "data",
+                        "textAlignment": "Left",
+                        "vAlign": "Middle",
+                        "x": 3,
+                        "y": 2,
+                        "width": 97,
+                        "height": 14
+                    },
+                    "item_1": {
+                        "type": "text",
+                        "source": "PAGE_INDEX",
+                        "source_type": "data",
+                        "source_isexpression":true,
+                        "textAlignment": "Right",
+                        "vAlign": "Middle",
+                        "x": 644,
+                        "y": 2,
+                        "width": 104,
+                        "height": 14
+                    }
+                }
+            },
+            "margin_left": 20,
+            "margin_right": 20,
+            "margin_top": 20,
+            "margin_bottom": 20,
             "contents": {
-                "count": 0,
-                "item_1": {
+                "count": 1,
+                "item_0": {
                     "type": "grid",
-                    "data_source": "table1_data",
+                    "data_source": "grid0",
                     "cell": {
-                        "direction": "V",
+                        "direction": "H",
                         "duplicate": 0,
-                        "data_source": "row0",
-                        "repeat": "horizontal",
+                        "data_source": "cell0",
+                        
                         "type": "group",
-                        "x": 10,
-                        "y": 10,
-                        "width": 100,
-                        "height": 200,
+                        "x": 0,
+                        "y": 0,
+                        "width": 250.66,
+                        "height": 244,
                         "items": {
-                            "count": 3,
+                            "count": 1,
                             "item_1": {
                                 "type": "line",
                                 "x0": 10,
@@ -148,12 +180,14 @@
                             },
                             "item_0": {
                                 "type": "img",
-                                "source": "image0",
+                                "source": "img",
                                 "source_type": "data",
-                                "x": 10,
-                                "y": 10,
-                                "width": 100,
-                                "height": 100
+                                "hAlign": "Center",
+                                "vAlign": "Middle",
+                                "x": 0,
+                                "y": 0,
+                                "width": 158,
+                                "height": 158
                             },
                             "item_2": {
                                 "type": "text",
@@ -168,61 +202,10 @@
                             }
                         }
                     },
-                    "x": 10,
-                    "y": 10,
-                    "width": 530,
-                    "height": 760
-                },
-                "item_0": {
-                    "type": "table",
-                    "data_source": "table1_data",
-                    "rows": {
-                        "count": 1,
-                        "row_0": {
-                            "data_source": "row0",
-                            "repeat": "horizontal",
-                            "type": "group",
-                            "x": 10,
-                            "y": 10,
-                            "width": 100,
-                            "height": 200,
-                            "items": {
-                                "count": 3,
-                                "item_1": {
-                                    "type": "line",
-                                    "x0": 10,
-                                    "y0": 10,
-                                    "x1": 100,
-                                    "y1": 100,
-                                    "line_width": 0.02
-                                },
-                                "item_0": {
-                                    "type": "img",
-                                    "source": "image0",
-                                    "source_type": "data",
-                                    "x": 10,
-                                    "y": 10,
-                                    "width": 100,
-                                    "height": 100
-                                },
-                                "item_2": {
-                                    "type": "text",
-                                    "source": "text0",
-                                    "source_type": "data",
-                                    "font": "font name",
-                                    "size": "15",
-                                    "x": 10,
-                                    "y": 10,
-                                    "width": 100,
-                                    "height": 100
-                                }
-                            }
-                        }
-                    },
-                    "x": 10,
-                    "y": 10,
-                    "width": 100,
-                    "height": -1
+                    "x": 0,
+                    "y": 0,
+                    "width": 752,
+                    "height": 491
                 }
             }
         }

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff