· 8 years ago · Jun 24, 2018, 08:26 PM
1i have to integrate these angular fusion charts in my present application can any one help me
2
3Hi if any one could solve plz mail to this id manu_urs143@yahoo.com plz help me
4
5
6this is my present application and this is running fine and my present requirement is i have to integrate fusion charts for my application
7this was the controller code
8
9
10class BatteryPowersController < ApplicationController
11 include AuthenticatedSystem
12 before_filter :login_required
13 layout 'sites'
14 #~ before_filter :battery_power_user_required
15 #~ before_filter :require_for_update, :only => [:edit_battery, :update_battery]
16 #~ before_filter :require_for_create, :only => [:new_battery, :create_battery]
17 #~ before_filter :require_for_delete, :only => [:delete]
18 #Tower CRUD Details
19
20 def new_battery
21 @site =Site.find(params[:site_id])
22 @current_user = self.current_user
23 @battery_power = BatteryPower.new
24 @battery_power. site = @site
25 @battery_power.user = @current_user
26 end
27 def edit_battery
28 @current_user = self.current_user
29 @site = Site.find(params[:site_id])
30 @battery_power = BatteryPower.find(params[:id])
31 end
32
33def create_battery
34 @current_user = self.current_user
35 @site = Site.find(params[:site_id])
36 @battery_power = BatteryPower.new(params[:battery_power])
37 @battery_power.user = @current_user
38 @battery_power.site = @site
39 if@battery_power.save
40 redirect_to :controller=>'map'
41 flash[:notice] ='Battery & Power details created succesfully.'
42 else
43 render :action => 'new_battery'
44 end
45 end
46
47 def update_battery
48 @current_user =self.current_user
49 @site =Site.find(params[:site_id])
50 @battery_power = BatteryPower.find(params[:id])
51 @battery_power.user = @current_user
52 @battery_power.site = @site
53 if @battery_power.update_attributes(params[:battery_power])
54 # Tracking update
55 siteupdate = SiteUpdate.new
56 siteupdate.user_id=current_user.id
57 siteupdate.site_id=@site.id
58 siteupdate.save
59 render :action => 'show_battery'
60 flash[:notice] ='Battery & Power updated succesfully.'
61 else
62 render :action =>'update_battery_power'
63 end
64 end
65
66 def show_battery
67 @current_user = self.current_user
68 @site = Site.find(params[:site_id])
69 @battery_power = BatteryPower.find(params[:id])
70 @battery_power.user = @current_user
71 @battery_power.site = @site
72 @recents = RecentVisitor.find_all
73 @last_updates = SiteUpdate.find(:all, :conditions=>["site_id=?",@site.id],:limit=>4,:order=>"created_at DESC")
74 end
75
76 protected
77
78 #~ def battery_power_user_required
79 #~ unless current_user.instance_of?(VendorUser) && current_user.vendor && (current_user.vendor.vendor_type_id.to_i == 4)
80 #~ flash[:error] = "Only battery power User can perform this action"
81 #~ redirect_to :controller => :map, :action => :index and return false
82 #~ end
83 #~ end
84
85 #~ def require_for_update
86 #~ unless [VendorUser::DESIGNATIONS[1], VendorUser::DESIGNATIONS[2], VendorUser::DESIGNATIONS[3]].include?(current_user.designation)
87 #~ flash[:error] = "Only appropriate designation can perform this action"
88 #~ redirect_to :controller => :map, :action => :index
89 #~ end
90 #~ end
91
92 #~ def require_for_create
93 #~ unless VendorUser::DESIGNATIONS[2] == current_user.designation
94 #~ flash[:error] = "Only appropriate designation can perform this action"
95 #~ redirect_to :controller => :map, :action => :index
96 #~ end
97 #~ end
98
99 #~ def require_for_delete
100 #~ unless [VendorUser::DESIGNATIONS[1], VendorUser::DESIGNATIONS[2]].include?(current_user.designation)
101 #~ flash[:error] = "Only appropriate designation can perform this action"
102 #~ redirect_to :controller => :map, :action => :index
103 #~ end
104 #~ end
105
106 end
107
108
109
110this is model code
111
112class BatteryPower < ActiveRecord::Base
113 belongs_to :site
114 belongs_to :user
115end
116
117
118This was the code in db
119
120class CreateBatteryPowers < ActiveRecord::Migration
121 def self.up
122 create_table :battery_powers do |t|
123 t.column :site_id, :integer
124 t.column :user_id, :integer
125 t.column :battery_type, :string
126 t.column :battery_ampere_capacity, :string
127 t.column :battery_no_of, :string
128 t.column :battery_make, :string
129 t.column :battery_installation_date, :date
130 t.column :battery_check_date, :date
131 t.column :battery_maint_carried_date, :date
132 t.column :batttery_maint_time, :time
133 t.column :battery_maint_cost, :string
134 t.column :battery_maint_due_date, :date
135 t.column :battery_maint_remarks, :string
136 t.column :battery_life, :string
137 end
138
139 end
140
141 def self.down
142 drop_table :battery_powers
143 end
144end
145
146
147
148These were the view code for create_battery
149
150<td> created battery & power scuccessfully </td>
151
152
153This was the view code for edit_battery
154
155<%= form_tag url_for (:controller =>"battery_powers", :action =>"update_battery", :site_id => @site.id, :id => @battery_power.id), :multipart => true %>
156
157
158
159<table width="100%" border="0" cellspacing="0" cellpadding="0">
160 <tr>
161 <td align="center" valign="top"><table width="1250" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
162 <tr>
163 <td valign="top"><div align="center">
164 <table width="1200" border="0" cellspacing="0" cellpadding="0">
165 <tr>
166 <td height="25"> </td>
167 </tr>
168 <tr>
169 <td><table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
170
171 </table></td>
172 </tr>
173
174 <tr>
175 <td valign="top">
176 <table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
177
178 <tr>
179 <td valign="top"><table width="1200" border="0" cellspacing="0" cellpadding="0">
180 <tr>
181 <td width="1050" valign="top" ><table width="1050" border="0" cellspacing="0" cellpadding="0">
182 <tr>
183 <td valign="top" background="/images/sitedevelopment_color.gif"><table width="1050" border="0" cellspacing="1" cellpadding="0">
184 <tr>
185 <td valign="top" bgcolor="#FFFFFF"><table width="1050" border="0" cellspacing="0" cellpadding="0">
186 <tr>
187 <td class="tabcenterbg" valign="baseline"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
188 <tr>
189 <td><p> </p></td>
190 </tr>
191 <tr>
192 <td valign="top"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
193 <tr>
194 <td width="18"><img src="/images/t_topleft.gif" alt="CSIP" width="18" height="25" /></td>
195 <td valign="top" background="/images/t_topcenter.gif"><div align="left"><img src="/images/batterybank.gif" alt="Battery Bank" width="102" height="25" /></div></td>
196 <td width="15"><img src="/images/t_topright.gif" alt="CSIP" width="15" height="25" /></td>
197 </tr>
198 <tr>
199 <td background="/images/t_sideleft1.gif"> </td>
200 <td valign="top"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
201 <tr>
202 <td colspan="3"> </td>
203 <td width="43"> </td>
204 <td width="417"> </td>
205 <td width="141"> </td>
206 </tr>
207
208 <tr>
209 <td height="35" colspan="3"><div align="left">Type of Batteries </div></td>
210 <td><div align="center">:</div></td>
211 <td><%= text_field 'battery_power', 'battery_type', :class=>"newinput" %></td>
212 <td> </td>
213 </tr>
214
215 <tr>
216 <td height="35" colspan="3"><div align="left">Ampere Hours Capacity </div></td>
217 <td><div align="center">:</div></td>
218 <td><%= text_field 'battery_power', 'battery_ampere_capacity', :class=>"newinput" %></td>
219 <td> </td>
220 </tr>
221 <tr>
222 <td height="35" colspan="3"><div align="left">No.of. Batteried </div></td>
223 <td><div align="center">:</div></td>
224 <td><%= text_field 'battery_power', 'battery_no_of', :class=>"newinput" %></td>
225 <td> </td>
226 </tr>
227 <tr>
228 <td height="35" colspan="3"><div align="left">Make</div></td>
229 <td><div align="center">:</div></td>
230 <td><%= text_field 'battery_power', 'battery_make', :class=>"newinput" %></td>
231 <td> </td>
232 </tr>
233 <tr>
234 <td height="35" colspan="3"><div align="left">Date of Installation </div></td>
235 <td><div align="center">:</div></td>
236 <td><%= text_field 'battery_power', 'battery_installation_date', :class=>"newinput" %></td>
237 <td> </td>
238 </tr>
239
240 <tr>
241 <td height="35" colspan="3"><div align="left">Checked on Date </div></td>
242 <td><div align="center">:</div></td>
243 <td><%= text_field 'battery_power', 'battery_check_date', :class=>"newinput" %></td>
244 <td> </td>
245 </tr>
246
247 <tr>
248 <td height="35" colspan="3"><div align="left">
249 <p><span class="news_txt">Maintenance </span><br />
250 Carried Out Date </p>
251 </div></td>
252 <td><div align="center">:</div></td>
253 <td><%= date_select 'battery_power', 'battery_maint_carried_date', :class=>"newinput" %></td>
254 <td> </td>
255 </tr>
256 <tr>
257 <td height="35" colspan="3"><div align="left">
258 <p>Time</p>
259 </div></td>
260 <td><div align="center">:</div></td>
261 <td><%= time_select 'battery_power', 'batttery_maint_time', :class=>"newinput" %></td>
262 <td> </td>
263 </tr>
264 <tr>
265 <td height="35" colspan="3"><div align="left">
266 <p>Cost</p>
267 </div></td>
268 <td><div align="center">:</div></td>
269 <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"newinput" %></td>
270 <td> </td>
271 </tr>
272 <tr>
273 <td height="35" colspan="3"><div align="left">Next Due Date </div></td>
274 <td><div align="center">:</div></td>
275 <td><%= date_select 'battery_power', 'battery_maint_due_date', :class=>"newinput" %></td>
276 <td> </td>
277 </tr>
278
279 <tr>
280 <td height="35" colspan="3"><div align="left">Remarks</div></td>
281 <td><div align="center">:</div></td>
282 <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"multiinput" %></td>
283 <td> </td>
284 </tr>
285
286
287 <tr>
288 <td height="20" colspan="3"> </td>
289 <td> </td>
290 <td> </td>
291 <td> </td>
292 </tr>
293 <tr>
294 <td height="20" colspan="3"> </td>
295 <td> </td>
296 <td><input type="image" src="/images/create_button.gif" alt="create" width="89" height="22" onClick="this.form.submit();" /></td>
297 <td> </td>
298 </tr>
299 </table></td>
300 <td background="/images/t_sideright1.gif"> </td>
301 </tr>
302 <tr>
303 <td><img src="/images/t_topbottom1.gif" width="18" height="14" /></td>
304 <td height="14" background="/images/t_bottomcenter1.gif"><img src="/images/t_bottomcenter.gif" alt="/images/t_sideright.gif" width="1" height="14" /></td>
305 <td><img src="/images/t_toprightbottom.gif" alt="/images/t_sideright.gif" width="15" height="14" /></td>
306 </tr>
307 </table></td>
308 </tr>
309 </table>
310 <br />
311<br />
312<br />
313<br />
314<br />
315<br />
316<br />
317<br />
318
319 </td>
320 </tr>
321 </table></td>
322 </tr>
323 </table></td>
324 </tr>
325 </table> <p> </p></td>
326 <td> </td>
327 <td valign="top"><div align="right"><img src="/images/add.gif" alt="Advertisement" width="120" height="600" /></div></td>
328 </tr>
329 </table></td>
330 </tr>
331
332 </table></td>
333 </tr>
334
335 </table>
336 </div></td>
337 </tr>
338 </table></td>
339 </tr>
340</table>
341<%= end_form_tag %>
342
343
344This was the view code for new_battery
345
346<%= form_tag url_for (:controller =>"battery_powers", :action =>"create_battery", :site_id => @site.id), :multipart => true %>
347
348
349
350<table width="100%" border="0" cellspacing="0" cellpadding="0">
351 <tr>
352 <td align="center" valign="top"><table width="1250" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
353 <tr>
354 <td valign="top"><div align="center">
355 <table width="1200" border="0" cellspacing="0" cellpadding="0">
356 <tr>
357 <td height="25"> </td>
358 </tr>
359 <tr>
360 <td><table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
361
362 </table></td>
363 </tr>
364
365 <tr>
366 <td valign="top">
367 <table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
368
369 <tr>
370 <td valign="top"><table width="1200" border="0" cellspacing="0" cellpadding="0">
371 <tr>
372 <td width="1050" valign="top" ><table width="1050" border="0" cellspacing="0" cellpadding="0">
373 <tr>
374 <td valign="top" background="/images/sitedevelopment_color.gif"><table width="1050" border="0" cellspacing="1" cellpadding="0">
375 <tr>
376 <td valign="top" bgcolor="#FFFFFF"><table width="1050" border="0" cellspacing="0" cellpadding="0">
377 <tr>
378 <td class="tabcenterbg" valign="baseline"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
379 <tr>
380 <td><p> </p></td>
381 </tr>
382 <tr>
383 <td valign="top"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
384 <tr>
385 <td width="18"><img src="/images/t_topleft.gif" alt="CSIP" width="18" height="25" /></td>
386 <td valign="top" background="/images/t_topcenter.gif"><div align="left"><img src="/images/batterybank.gif" alt="Battery Bank" width="102" height="25" /></div></td>
387 <td width="15"><img src="/images/t_topright.gif" alt="CSIP" width="15" height="25" /></td>
388 </tr>
389 <tr>
390 <td background="/images/t_sideleft1.gif"> </td>
391 <td valign="top"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
392 <tr>
393 <td colspan="3"> </td>
394 <td width="43"> </td>
395 <td width="417"> </td>
396 <td width="141"> </td>
397 </tr>
398
399 <tr>
400 <td height="35" colspan="3"><div align="left">Type of Batteries </div></td>
401 <td><div align="center">:</div></td>
402 <td><%= text_field 'battery_power', 'battery_type', :class=>"newinput" %></td>
403 <td> </td>
404 </tr>
405
406 <tr>
407 <td height="35" colspan="3"><div align="left">Ampere Hours Capacity </div></td>
408 <td><div align="center">:</div></td>
409 <td><%= text_field 'battery_power', 'battery_ampere_capacity', :class=>"newinput" %></td>
410 <td> </td>
411 </tr>
412 <tr>
413 <td height="35" colspan="3"><div align="left">No.of. Batteried </div></td>
414 <td><div align="center">:</div></td>
415 <td><%= text_field 'battery_power', 'battery_no_of', :class=>"newinput" %></td>
416 <td> </td>
417 </tr>
418 <tr>
419 <td height="35" colspan="3"><div align="left">Make</div></td>
420 <td><div align="center">:</div></td>
421 <td><%= text_field 'battery_power', 'battery_make', :class=>"newinput" %></td>
422 <td> </td>
423 </tr>
424 <tr>
425 <td height="35" colspan="3"><div align="left">Date of Installation </div></td>
426 <td><div align="center">:</div></td>
427 <td><%= date_select 'battery_power', 'battery_installation_date', :class=>"newinput" %></td>
428 <td> </td>
429 </tr>
430
431 <tr>
432 <td height="35" colspan="3"><div align="left">Checked on Date </div></td>
433 <td><div align="center">:</div></td>
434 <td><%= date_select 'battery_power', 'battery_check_date', :class=>"newinput" %></td>
435 <td> </td>
436 </tr>
437
438 <tr>
439 <td height="35" colspan="3"><div align="left">
440 <p><span class="news_txt">Maintenance </span><br />
441 Carried Out Date </p>
442 </div></td>
443 <td><div align="center">:</div></td>
444 <td><%= date_select 'battery_power', 'battery_maint_carried_date', :class=>"newinput" %></td>
445 <td> </td>
446 </tr>
447 <tr>
448 <td height="35" colspan="3"><div align="left">
449 <p>Time</p>
450 </div></td>
451 <td><div align="center">:</div></td>
452 <td><%= time_select 'battery_power', 'batttery_maint_time', :class=>"newinput" %></td>
453 <td> </td>
454 </tr>
455 <tr>
456 <td height="35" colspan="3"><div align="left">
457 <p>Cost</p>
458 </div></td>
459 <td><div align="center">:</div></td>
460 <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"newinput" %></td>
461 <td> </td>
462 </tr>
463 <tr>
464 <td height="35" colspan="3"><div align="left">Next Due Date </div></td>
465 <td><div align="center">:</div></td>
466 <td><%= date_select 'battery_power', 'battery_maint_due_date', :class=>"newinput" %></td>
467 <td> </td>
468 </tr>
469
470 <tr>
471 <td height="35" colspan="3"><div align="left">Remarks</div></td>
472 <td><div align="center">:</div></td>
473 <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"multilineinput" %></td>
474 <td> </td>
475 </tr>
476
477
478 <tr>
479 <td height="20" colspan="3"> </td>
480 <td> </td>
481 <td> </td>
482 <td> </td>
483 </tr>
484 <tr>
485 <td height="20" colspan="3"> </td>
486 <td> </td>
487 <td><input type="image" src="/images/create_button.gif" alt="create" width="89" height="22" onClick="this.form.submit();"/></td>
488 <td> </td>
489 </tr>
490 </table></td>
491 <td background="/images/t_sideright1.gif"> </td>
492 </tr>
493 <tr>
494 <td><img src="/images/t_topbottom1.gif" width="18" height="14" /></td>
495 <td height="14" background="/images/t_bottomcenter1.gif"><img src="/images/t_bottomcenter.gif" alt="/images/t_sideright.gif" width="1" height="14" /></td>
496 <td><img src="/images/t_toprightbottom.gif" alt="/images/t_sideright.gif" width="15" height="14" /></td>
497 </tr>
498 </table></td>
499 </tr>
500 </table>
501 <br />
502<br />
503<br />
504<br />
505<br />
506<br />
507<br />
508<br />
509
510 </td>
511 </tr>
512 </table></td>
513 </tr>
514 </table></td>
515 </tr>
516 </table> <p> </p></td>
517 <td> </td>
518 <td valign="top"><div align="right"><img src="/images/add.gif" alt="Advertisement" width="120" height="600" /></div></td>
519 </tr>
520 </table></td>
521 </tr>
522
523 </table></td>
524 </tr>
525
526 </table>
527 </div></td>
528 </tr>
529 </table></td>
530 </tr>
531</table>
532</body>
533</html>
534
535
536<%= end_form_tag %>
537
538
539This was the view code for show_battery
540
541<%= form_tag url_for (:controller =>"battery_powers", :action =>"create_battery", :site_id => @site.id), :multipart => true %>
542
543
544
545<table width="100%" border="0" cellspacing="0" cellpadding="0">
546 <tr>
547 <td align="center" valign="top"><table width="1250" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
548 <tr>
549 <td valign="top"><div align="center">
550 <table width="1200" border="0" cellspacing="0" cellpadding="0">
551 <tr>
552 <td height="25"> </td>
553 </tr>
554 <tr>
555 <td><table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
556
557 </table></td>
558 </tr>
559
560 <tr>
561 <td valign="top">
562 <table width="1200" border="0" align="center" cellpadding="0" cellspacing="0">
563
564 <tr>
565 <td valign="top"><table width="1200" border="0" cellspacing="0" cellpadding="0">
566 <tr>
567 <td width="1050" valign="top" ><table width="1050" border="0" cellspacing="0" cellpadding="0">
568 <tr>
569 <td valign="top" background="/images/sitedevelopment_color.gif"><table width="1050" border="0" cellspacing="1" cellpadding="0">
570 <tr>
571 <td valign="top" bgcolor="#FFFFFF"><table width="1050" border="0" cellspacing="0" cellpadding="0">
572 <tr>
573 <td class="tabcenterbg" valign="baseline"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
574 <tr>
575 <td><p> </p></td>
576 </tr>
577 <tr>
578 <td valign="top"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
579 <tr>
580 <td width="18"><img src="/images/t_topleft.gif" alt="CSIP" width="18" height="25" /></td>
581 <td valign="top" background="/images/t_topcenter.gif"><div align="left"><img src="/images/batterybank.gif" alt="Battery Bank" width="102" height="25" /></div></td>
582 <td width="15"><img src="/images/t_topright.gif" alt="CSIP" width="15" height="25" /></td>
583 </tr>
584 <tr>
585 <td background="/images/t_sideleft1.gif"> </td>
586 <td valign="top"><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
587 <tr>
588 <td colspan="3"> </td>
589 <td width="43"> </td>
590 <td width="417"> </td>
591 <td width="141"> </td>
592 </tr>
593
594 <tr>
595 <td height="35" colspan="3"><div align="left">Type of Batteries </div></td>
596 <td><div align="center">:</div></td>
597 <td><%= text_field 'battery_power', 'battery_type', :class=>"newinput" %></td>
598 <td> </td>
599 </tr>
600
601 <tr>
602 <td height="35" colspan="3"><div align="left">Ampere Hours Capacity </div></td>
603 <td><div align="center">:</div></td>
604 <td><%= text_field 'battery_power', 'battery_ampere_capacity', :class=>"newinput" %></td>
605 <td> </td>
606 </tr>
607 <tr>
608 <td height="35" colspan="3"><div align="left">No.of. Batteried </div></td>
609 <td><div align="center">:</div></td>
610 <td><%= text_field 'battery_power', 'battery_no_of', :class=>"newinput" %></td>
611 <td> </td>
612 </tr>
613 <tr>
614 <td height="35" colspan="3"><div align="left">Make</div></td>
615 <td><div align="center">:</div></td>
616 <td><%= text_field 'battery_power', 'battery_make', :class=>"newinput" %></td>
617 <td> </td>
618 </tr>
619 <tr>
620 <td height="35" colspan="3"><div align="left">Date of Installation </div></td>
621 <td><div align="center">:</div></td>
622 <td><%= date_select 'battery_power', 'battery_installation_date', :class=>"newinput" %></td>
623 <td> </td>
624 </tr>
625
626 <tr>
627 <td height="35" colspan="3"><div align="left">Checked on Date </div></td>
628 <td><div align="center">:</div></td>
629 <td><%= date_select 'battery_power', 'battery_check_date', :class=>"newinput" %></td>
630 <td> </td>
631 </tr>
632
633 <tr>
634 <td height="35" colspan="3"><div align="left">
635 <p><span class="news_txt">Maintenance </span><br />
636 Carried Out Date </p>
637 </div></td>
638 <td><div align="center">:</div></td>
639 <td><%= date_select 'battery_power', 'battery_maint_carried_date', :class=>"newinput" %></td>
640 <td> </td>
641 </tr>
642 <tr>
643 <td height="35" colspan="3"><div align="left">
644 <p>Time</p>
645 </div></td>
646 <td><div align="center">:</div></td>
647 <td><%= time_select 'battery_power', 'batttery_maint_time', :class=>"newinput" %></td>
648 <td> </td>
649 </tr>
650 <tr>
651 <td height="35" colspan="3"><div align="left">
652 <p>Cost</p>
653 </div></td>
654 <td><div align="center">:</div></td>
655 <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"newinput" %></td>
656 <td> </td>
657 </tr>
658 <tr>
659 <td height="35" colspan="3"><div align="left">Next Due Date </div></td>
660 <td><div align="center">:</div></td>
661 <td><%= date_select 'battery_power', 'battery_maint_due_date', :class=>"newinput" %></td>
662 <td> </td>
663 </tr>
664
665 <tr>
666 <td height="35" colspan="3"><div align="left">Remarks</div></td>
667 <td><div align="center">:</div></td>
668 <td><%= text_field 'battery_power', 'battery_maint_cost', :class=>"multilineinput" %></td>
669 <td> </td>
670 </tr>
671
672
673 <tr>
674 <td height="20" colspan="3"> </td>
675 <td> </td>
676 <td> </td>
677 <td> </td>
678 </tr>
679 <tr>
680 <td height="20" colspan="3"> </td>
681 <td> </td>
682 <td><input type="image" src="/images/create_button.gif" alt="create" width="89" height="22" onClick="this.form.submit();"/></td>
683 <td> </td>
684 </tr>
685 </table></td>
686 <td background="/images/t_sideright1.gif"> </td>
687 </tr>
688 <tr>
689 <td><img src="/images/t_topbottom1.gif" width="18" height="14" /></td>
690 <td height="14" background="/images/t_bottomcenter1.gif"><img src="/images/t_bottomcenter.gif" alt="/images/t_sideright.gif" width="1" height="14" /></td>
691 <td><img src="/images/t_toprightbottom.gif" alt="/images/t_sideright.gif" width="15" height="14" /></td>
692 </tr>
693 </table></td>
694 </tr>
695 </table>
696 <br />
697<br />
698<br />
699<br />
700<br />
701<br />
702<br />
703<br />
704
705 </td>
706 </tr>
707 </table></td>
708 </tr>
709 </table></td>
710 </tr>
711 </table> <p> </p></td>
712 <td> </td>
713 <td valign="top"><div align="right"><img src="/images/add.gif" alt="Advertisement" width="120" height="600" /></div></td>
714 </tr>
715 </table></td>
716 </tr>
717
718 </table></td>
719 </tr>
720
721 </table>
722 </div></td>
723 </tr>
724 </table></td>
725 </tr>
726</table>
727</body>
728</html>
729
730
731<%= end_form_tag %>
732
733
734The problem is how can i integrate these angular fusion charts in my application they have to changed dynamically as soon i give the minimum and
735maximum values to it
736
737This was the code i found but i was unable to integrate this in my application can any one help me
738
739
740
741
742
743class Fusioncharts::FcExporterController < ApplicationController
744 require 'fusioncharts/exporter/error_handler'
745 require 'fusioncharts/exporter/properties'
746
747 def index
748
749 @fc_exporter= Fusioncharts::Exporter::FcExporter.new(params)
750
751 target=@fc_exporter.exporttargetwindow
752 filename = @fc_exporter.exportfilename
753 exportaction = @fc_exporter.exportaction
754 is_html = exportaction.eql?("download")
755
756 validation_result = @fc_exporter.validate # Should return true if validated, or fc_error
757 if(validation_result.kind_of?(Fusioncharts::Exporter::FcError) )
758 print "%%%%% WArnings"+validation_result.warnings
759 print "$$$$$ Errors="+validation_result.code2message
760 Fusioncharts::Exporter::ErrorHandler.set_flash_err(validation_result,flash,is_html,@fc_exporter.meta)
761 # Error has occurred, quit further processing
762 redirect_to :action=>'error',:target=>target
763 return
764 end
765
766
767 logger.info "Export Action="+ exportaction
768
769 format = @fc_exporter.exportformat
770 handler =@fc_exporter.format_handler(format.upcase)
771
772 if(handler.kind_of?(Fusioncharts::Exporter::FcError))
773 Fusioncharts::Exporter::ErrorHandler.set_flash_err(handler,flash,is_html,@fc_exporter.meta)
774 # Error has occurred, quit further processing
775 redirect_to :action=>'error',:target=>target
776 return
777 end
778
779 export_object,fc_error=handler.process_export(@fc_exporter.stream,@fc_exporter.meta,format)
780
781 if(fc_error.kind_of?(Fusioncharts::Exporter::FcError))
782 Fusioncharts::Exporter::ErrorHandler.set_flash_err(fc_error,flash,is_html,@fc_exporter.meta)
783 # Error has occurred, quit further processing
784 redirect_to :action=>'error',:target=>target
785 return
786 end
787 logger.info("Processed using the Format Handler. Proceeding to download/save...")
788
789 ext =@fc_exporter.extension(format)
790
791 if(exportaction=="download")
792 mime_type = @fc_exporter.mime_type(ext)
793 logger.info("Setting mime type as "+mime_type)
794 headers["content-type"]=mime_type
795 if(target.downcase == "_self")
796 headers["Content-Disposition"]='attachment'
797 else
798 headers["Content-Disposition"]='inline'
799 end
800 headers["filename"]=" " + filename +"."+ ext
801
802 send_data(export_object, {:type => mime_type, :stream => true, :filename => " " + filename +"."+ ext})
803 #render :content_type => 'application/octet-stream', :text => Proc.new { |response, output|
804 # do something that reads data and writes it to output
805 #export_object
806 #}
807 #~ #Testing
808 #~ f = File.open("C:/"+filename+"."+ext, 'wb');
809 #~ f.write export_object
810 #~ f.close
811 else
812 # Save on server
813 complete_file_path,displayPath, notice = @fc_exporter.determine_path_to_save
814 handler.write_to_file(complete_file_path)
815 logger.info "Saved to location on server: "+displayPath
816 meta_values=Fusioncharts::Exporter::ErrorHandler.meta2qs(@fc_exporter.meta,displayPath)
817 render :text=>"statusCode=1&statusMessage=successful"+notice+meta_values
818 end
819 end
820
821 # This action will render the errors, shows the error.html.erb which contains flash[:notice] and flash[:error]
822 # To build the error message as response, build_error_response method from Fusioncharts::Exporter::ErrorHandler is used
823 def error
824 target = params[:target]
825 headers["Content-type"]="text/html"
826 if(target.downcase == "_self")
827 headers["Content-Disposition"]='attachment'
828 else
829 headers["Content-Disposition"]='inline'
830 end
831
832 logger.info("Rendering Error Page")
833 end
834
835
836end
837
838
839this is in lib folder
840
841# Contains method to help build the error message
842class Fusioncharts::Exporter::ErrorHandler
843 # Sets the errors in flash object. These flash messages can later be output in error view page
844 # This method should ideally be called only once in the program execution. When an error occurs and the program halts and wants to show the error
845 def self.set_flash_err(fc_error,flash,is_html,meta,fileName=nil)
846 error_msgs = is_html ? fc_error.error2html : fc_error.error2qs
847 warning_msgs= is_html ? fc_error.warnings2html : fc_error.warnings2qs
848 flash[:notice]=warning_msgs
849 flash[:error]=error_msgs
850 separator = (is_html ? "<br>" : "&")
851 meta_new = meta
852 if(!fc_error.empty?)
853 # This means error has occured, hence statusCode=0
854 # Values for width and height are 0 in case of error. FileName is empty.
855 width ="0"
856 height="0"
857 displayPath=""
858 meta_new.update({"width"=>width,"height"=>height})
859 else
860 # status code =1
861 flash[:error]+=separator+"statusCode=1"
862 # Values for width and height in case of success. FileName is path to the file on server.
863 displayPath =Fusioncharts::Exporter::Properties.HTTP_URI.gsub!(/\/$/, '') + "/" +fileName
864 end
865 # Whether success or failure, add file URI , width and height and DomId when status success
866 flash[:error]+= is_html ? meta2html(meta_new,displayPath) : meta2qs(meta_new,displayPath)
867 end
868 # Builds the query string starting with & for meta values
869 def self.meta2qs(meta,fileNameWithPath)
870 meta_values=""
871 if(!fileNameWithPath.nil?)
872 meta_values+="&fileName="+fileNameWithPath
873 end
874 meta_values+= "&width=" +meta ["width"]
875 meta_values+= "&height=" +meta ["height"]
876 meta_values+= "&DOMId=" +meta ["DOMId"]
877 return meta_values
878 end
879 def self.meta2html(meta,fileNameWithPath)
880 meta_values=""
881 if(!fileNameWithPath.nil?)
882 meta_values="<br>fileName="+fileNameWithPath
883 end
884 meta_values+= "<br>width=" +meta ["width"]
885 meta_values+= "<br>height=" +meta ["height"]
886 meta_values+= "<br>DOMId=" +meta ["DOMId"]
887 return meta_values
888 end
889
890end
891
892
893class Fusioncharts::Exporter::ErrorMessages
894 @@err_messages={"E100"=> "Insufficient Data.",
895 "E101" => "Width/height not provided.",
896 "E102" => "Insufficient export parameters.",
897 "E400" => "Bad Request.",
898 "E401"=> "Unauthorized Access.",
899 "E403"=> "Access Forbidden.",
900 "E404" => "Export Resource not found.",
901 "E507" => "Insufficient Storage.",
902 "E508" => "Server Directory does not exist.",
903 "W509" => "File already exists.",
904 "W510" => "Export handler's Overwrite setting is on. Trying to overwrite.",
905 "E511" => "Overwrite forbidden. File cannot be overwritten."
906 }
907
908 def self.get_error_message(error_code)
909 err_message = @@err_messages[error_code.to_s]
910 return err_message
911 end
912end
913
914
915class Fusioncharts::Exporter::FcError
916 #TODO Change this to attr_accessor
917 attr_reader :warn_codes,:err_code
918
919 @@err_messages={
920 "E100"=> "Insufficient Data.",
921 "E101" => "Width/height not provided.",
922 "E102" => "Insufficient export parameters.",
923 "E400" => "Bad Request.",
924 "E401"=> "Unauthorized Access.",
925 "E403"=> "Access Forbidden.",
926 "E404" => "Export Resource not found.",
927 "E507" => "Insufficient Storage.",
928 "E508" => "Server Directory does not exist.",
929 "W509" => "File already exists.",
930 "W510" => "Export handler's Overwrite setting is on. Trying to overwrite.",
931 "E511" => "Overwrite forbidden. File cannot be overwritten.",
932 "E512" => "Intelligent File Naming is Turned off",
933 "W513" => " Background color not specified. Taking White (FFFFF) as default background color.",
934 "E514" => " Error while creating binary data.",
935 "E515" => " Problem creating the image. Please verify that RMagick is installed correctly.",
936 "E516" => " Problem creating the PDF data. Please verify that Zlib is installed correctly."
937 }
938
939 def initialize(ierror_code="",warning_codes=Array.new)
940 @err_code = ierror_code
941 @warn_codes = warning_codes
942 end
943
944 def warning_codes
945 return @warn_codes
946 end
947
948 def error_code
949 return @err_code
950 end
951
952
953 def warnings
954 warning_msgs=""
955 0.upto(@warn_codes.length-1) do |i|
956 message = Fusioncharts::Exporter::FcError.warning_message(@warn_codes[i])
957 if(message == nil or message.empty?)
958 message = "Could not find warning message for "+ @warn_codes[i]
959 end
960 # This is just a warning/notice
961 warning_msgs+=message
962 end
963 return warning_msgs
964 end
965
966 def add_warning(warning_code)
967 @warn_codes << warning_code
968 end
969
970 def set_error_code(ierror_code)
971 @err_code = ierror_code
972 end
973
974 #Gets the error message for a particular code, returns nil if not found
975 def code2message()
976 err_message = @@err_messages["E"+@err_code.to_s]
977 return err_message
978 end
979
980 def empty?
981 return @err_code.nil? || @err_code.empty? || @err_code==""
982 end
983
984 def no_warnings?
985 return @warn_codes.empty?
986 end
987
988
989 def error2qs
990 error_str=""
991 if(@err_code==nil or @err_code.empty?)
992 error_str+="&statusMessage=successful&statusCode=1"
993 else
994 error_str+="&statusMessage="+code2message+"&statusCode=0"
995 end
996 return error_str
997 end
998
999 def warnings2qs
1000 error_str = "¬ice="+warnings
1001 return error_str
1002 end
1003
1004 def error2html
1005 error_str = ""
1006 if(@err_code==nil or @err_code.empty?)
1007 error_str+="<br>statusMessage=successful<br>statusCode=1"
1008 else
1009 error_str+="<br>statusMessage="+code2message+"<br>statusCode=0"
1010 end
1011 return error_str
1012 end
1013
1014 def warnings2html
1015 error_str = "<br>notice="+warnings
1016 return error_str
1017 end
1018
1019
1020 def to_qs
1021 error_str = warnings2qs
1022 error_str+=error2qs
1023 end
1024
1025 def to_html
1026 error_str = warnings2html
1027 error_str+=error2html
1028 end
1029
1030#Gets the error message for a particular code, returns nil if not found
1031 def self.code2message(err_code)
1032 err_message = @@err_messages[err_code.to_s]
1033 return err_message
1034 end
1035
1036 def self.warning_message(warning_code)
1037 message = code2message("W"+warning_code)
1038 return message
1039 end
1040
1041
1042end
1043
1044class Fusioncharts::Exporter::FcExporter
1045
1046 @@default_parameter_values = {"exportfilename"=>"FusionCharts", "exportaction"=>"download", "exporttargetwindow"=>"_self", "exportformat"=>"PDF"}
1047 @@mime_list = {"jpg"=>"image/jpeg", "jpeg"=>"image/jpeg", "png"=>"image/png", "pdf"=>"application/pdf"}
1048 @@ext_list = {"jpg"=>"jpg", "jpeg"=>"jpg", "png"=>"png","pdf"=>"pdf"}
1049
1050 # Can access these attributes
1051 attr_reader :parsed_params
1052 attr_reader :exportfilename,:exportaction,:exportformat,:exporttargetwindow
1053 attr_reader :meta
1054 # Note: Not providing an accessor for stream, as this will be huge data, instead defining a method
1055
1056 def initialize(params)
1057 @params = params
1058 @parsed_params = parse_export_request_stream
1059 @exportfilename = @parsed_params['parameters']['exportfilename']
1060 @exportaction = @parsed_params['parameters']['exportaction']
1061 @exportformat = @parsed_params['parameters']['exportformat']
1062 @exporttargetwindow = @parsed_params['parameters']['exporttargetwindow']
1063 #@parsed_params['parameters']['exportcallback']='FC_Exported'
1064 @meta = @parsed_params['meta']
1065 end
1066 # All exceptions need to be handled in the caller
1067 def validate
1068 result=true
1069 validation_result=validate_parameters
1070 if(validation_result.kind_of?(Fusioncharts::Exporter::FcError) && !validation_result.empty?)
1071 return validation_result
1072 end
1073 #export_action = @parsed_params['parameters']['exportaction']
1074
1075 if(!@exportaction.eql?("download"))
1076 validation_result=validate_for_save(@exportfilename,@exportformat.downcase)
1077 if(validation_result.kind_of?(Fusioncharts::Exporter::FcError) && !validation_result.empty?)
1078 return validation_result
1079 end
1080 end
1081 return result
1082 end
1083
1084 # Check if width, height and stream parameters are in order
1085 def validate_parameters
1086 validation_result = true
1087 validation_error = Fusioncharts::Exporter::FcError.new
1088 if(@params[:meta_bgColor].nil?)
1089 validation_error.add_warning("513")
1090 validation_result =false
1091 end
1092 if(@params[:stream].nil?)
1093 validation_result =false
1094 validation_error.set_error_code("100")
1095 elsif(@params[:meta_width].nil? or @params[:meta_height].nil? or @params[:meta_width].eql?("0") or @params[:meta_height].eql?("0"))
1096 validation_result =false
1097 validation_error.set_error_code("101")
1098 end
1099 return validation_result ? validation_result : validation_error
1100 end
1101
1102 # Check if server is ready for save action
1103 def validate_for_save(filename,extension)
1104 #TODO Check if SAVEPATH ends with / otherwise append /
1105 abs_path = File.expand_path(Fusioncharts::Exporter::Properties.SAVEPATH)
1106 server_save_status= Fusioncharts::Exporter::SaveHelper.check_server_save_status(abs_path,filename+"."+extension,Fusioncharts::Exporter::Properties.OVERWRITEFILE,Fusioncharts::Exporter::Properties.INTELLIGENTFILENAMING)
1107 return server_save_status
1108 end
1109 def parse_export_request_stream
1110 #String of compressed data
1111 #Get all export parameters
1112 #get width and height of the chart
1113 #Background color of chart
1114 meta_hash = {"width"=>@params[:meta_width],
1115 "height"=>@params[:meta_height],
1116 "bgColor"=>@params[:meta_bgColor],
1117 "DOMId"=>@params[:meta_DOMId]}
1118
1119 export_data = {"stream"=>@params[:stream],
1120 "parameters"=>parse_params(@params[:parameters]),
1121 "meta"=>meta_hash}
1122
1123 return export_data
1124 end
1125
1126 def parse_params(str_params)
1127 params_values = bang str_params
1128 @@default_parameter_values.update(params_values)
1129 return @@default_parameter_values
1130 end
1131
1132 def bang(parameters_str)
1133 delimiter_list = ["|","="]
1134 ret_hash = Hash.new([].freeze)
1135
1136 parameters_str.split(delimiter_list[0]).each do |pairs|
1137 key, value = pairs.split('=',2).collect{|v| CGI::unescape(v) }
1138 if value!=nil && !value.empty?
1139 ret_hash[key.downcase] = value
1140 end
1141 end
1142 return ret_hash
1143 end
1144
1145
1146 def format_handler(str_format)
1147 fc_error=nil
1148 exporter_klass=nil
1149 if(Fusioncharts::Exporter::Properties.HANDLERASSOCIATIONSHASH[str_format] != nil)
1150 exporter_suffix = Fusioncharts::Exporter::Properties.HANDLERASSOCIATIONSHASH[str_format]
1151 else
1152 exporter_suffix = str_format
1153 end
1154 class_name_str = ((Fusioncharts::Exporter::Properties.RESOURCEPATH+Fusioncharts::Exporter::Properties.EXPORTHANDLER+ (exporter_suffix.downcase)).camelize)
1155 # Check if Corresponding Resource Handler Class is present
1156 if(class_exists?(class_name_str))
1157 class_name= class_name_str.constantize
1158 exporter_klass=class_name.new
1159 else
1160 #error_codes="E404,"
1161 fc_error=Fusioncharts::Exporter::FcError.new("404")
1162 end
1163 return exporter_klass==nil ? fc_error : exporter_klass
1164 #Object.const_get(Fusioncharts::Exporter::Properties.BASEPACKAGE).const_get(Fusioncharts::Exporter::Properties.EXPORTERPACKAGE).const_get((Fusioncharts::Exporter::Properties.EXPORTHANDLER + exporter_suffix.downcase).camelize).new
1165 end
1166
1167# Before calling this method, validate should have been called. This method does not validate for save again
1168 def determine_path_to_save
1169 filename = @exportfilename
1170 format = @exportformat
1171 ext=format.downcase
1172 notice ="¬ice="
1173 #logger.info "Saving to file on server"
1174 # Save File on server
1175 folder_to_save = File.expand_path(Fusioncharts::Exporter::Properties.SAVEPATH)
1176 #build filepath
1177 complete_file_path = File.join(folder_to_save,filename +"." + ext)
1178 #folder_to_save + '/' + filename +"." + ext
1179 displayFileName = filename +"." + ext
1180 #Check if file exists and create new filename
1181 if(FileTest.exists?(complete_file_path))
1182 notice += " File already exists."
1183 if( !Fusioncharts::Exporter::Properties.OVERWRITEFILE)
1184 notice+= " Using intelligent naming of file by adding an unique suffix to the exising name."
1185 # create new filename
1186 complete_file_path= Fusioncharts::Exporter::SaveHelper.generate_unique_filename(folder_to_save + '/' + filename ,ext)
1187 displayFileName=File.basename(complete_file_path)
1188 notice+= "The filename has changed to "+displayFileName
1189 end
1190 end
1191 #logger.info "Saving to location "+complete_file_path
1192 http_path = Fusioncharts::Exporter::Properties.HTTP_URI.gsub!(/\/$/, '')
1193 if(http_path==nil)
1194 http_path = Fusioncharts::Exporter::Properties.HTTP_URI
1195 end
1196 displayPath= File.join(http_path,displayFileName)
1197 return complete_file_path,displayPath,notice
1198 end
1199
1200 def mime_type(ext)
1201 m_type =ext
1202 if(@@mime_list[ext] != nil)
1203 m_type = @@mime_list[ext]
1204 end
1205 return m_type
1206 end
1207
1208 def extension(format)
1209 ext = format.downcase
1210 if(@@ext_list[ext] != nil)
1211 ext = @@ext_list[ext]
1212 end
1213 return ext
1214 end
1215 def stream
1216 return @parsed_params["stream"]
1217 end
1218
1219private
1220
1221 def class_exists?(class_name_str)
1222 begin
1223 true if class_name_str.constantize
1224 rescue NameError
1225 false
1226 end
1227 end
1228
1229end
1230
1231
1232=begin
1233
1234 Copyright (c) 2009 Infosoft Global Private Limited
1235
1236=end
1237class Fusioncharts::Exporter::FcExporterImg
1238 require 'fusioncharts/exporter/generator'
1239
1240 #FusionCharts Exporter - IMAGE Class
1241 #version 2.0 [ 19 February 2009]
1242
1243# Function to handle the export process
1244 def process_export(stream,meta,format)
1245 fc_error = nil
1246 @image=nil
1247 #ext = format.downcase
1248 @image=nil
1249 begin
1250 image_generator = Fusioncharts::Exporter::Generator::ImageGenerator.new(stream, meta["width"].to_i, meta["height"].to_i, meta["bgColor"],format)
1251 @image=image_generator.get_image
1252 rescue Exception => e
1253 print "Exception occurred="+e.to_s
1254 fc_error= Fusioncharts::Exporter::FcError.new("515")
1255 end
1256 return @image!=nil ? @image.to_blob : @image,fc_error!=nil ? fc_error : true
1257
1258 end
1259
1260 def write_to_file(fileName)
1261 @image.write(fileName)
1262 end
1263end
1264
1265
1266=begin
1267
1268 Copyright (c) 2009 Infosoft Global Private Limited
1269
1270=end
1271class Fusioncharts::Exporter::FcExporterPdf
1272 require 'fusioncharts/exporter/generator'
1273
1274 #FusionCharts Exporter - PDF Class
1275 #version 2.0 [ 05 March 2009 ] - Added error handling, restructured the code.
1276 #version 1.0 [ 03 March 2009] - Converted from controller to ruby class
1277
1278# Function to handle the export process
1279 def process_export(stream,meta,format)
1280 fc_error=nil
1281 @pdf_binary=nil
1282 begin
1283 fc_exporter = Fusioncharts::Exporter::Generator::PDFGenerator.new(stream, meta["width"].to_i, meta["height"].to_i, meta["bgColor"])
1284 # Parameter whether to compress the data or not
1285 @pdf_binary=fc_exporter.get_pdf_objects(true)
1286 #logger.info "PDF Binary created"
1287 rescue Exception => e
1288 print "Exception occurred="+e.to_s
1289 fc_error= Fusioncharts::Exporter::FcError.new("516")
1290 end
1291 return @pdf_binary,fc_error!=nil ? fc_error : true
1292
1293 end
1294
1295 def write_to_file(fileName)
1296 f = File.open(fileName, 'wb');
1297 f.write @pdf_binary
1298 f.close
1299 end
1300
1301end
1302
1303
1304=begin
1305
1306 Copyright (c) 2009 Infosoft Global Private Limited
1307
1308=end
1309module Fusioncharts::Exporter::Generator
1310 class PDFGenerator
1311 require 'zlib'
1312
1313 # attr :image_data
1314 # attr :width
1315 # attr :height
1316 # attr :bgcolor
1317 # attr :compress
1318 # Instance Methods
1319 # ----------------
1320 def initialize(image_data,width,height,bgcolor)
1321 # @image_data=image_data
1322 # @width=width
1323 # @height=height
1324 # @bgcolor=bgcolor
1325 @pages_data=[]
1326 @pageIndex=0
1327 if(image_data!=nil and width!=nil and height!=nil)
1328 set_bitmap_data(image_data, width, height, bgcolor)
1329 else
1330 # raise error
1331 end
1332 end
1333
1334 def set_bitmap_data(imageData_FCFormat, width, height, bgcolor="ffffff")
1335 @pages_data[@pageIndex]= {:width=>width,:height=>height,:bgcolor=>bgcolor,:image_data=>imageData_FCFormat}
1336 @pageIndex = @pageIndex+1
1337 end
1338
1339
1340 def get_pdf_objects(compress=true)
1341 @compress = compress
1342 pdf_bytes =""
1343 #Store all PDF objects in this temporary string to be written to ByteArray
1344 str_tmp_obj=""
1345 xref_list=[]
1346 xref_index =0
1347 #start xref array
1348 xref_list[xref_index]="xref\n0 "
1349 xref_index+=xref_index
1350
1351 xref_list[xref_index]="0000000000 65535 f \n" #Address Refenrece to obj 0
1352 xref_index+=xref_index
1353
1354 #Build PDF objects sequentially
1355 #version and header
1356 str_tmp_obj="%PDF-1.3\n%{FC}\n"
1357 pdf_bytes+=str_tmp_obj
1358
1359 #OBJECT 1 : info (optional)
1360 str_tmp_obj="1 0 obj<<\n/Author (FusionCharts)\n/Title (FusionCharts)\n/Creator (FusionCharts)\n>>\nendobj\n"
1361 xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 1
1362 xref_index+=xref_index
1363 pdf_bytes+=str_tmp_obj
1364
1365 #OBJECT 2 : Starts with Pages Catalogue
1366 str_tmp_obj="2 0 obj\n<< /Type /Catalog /Pages 3 0 R >>\nendobj\n"
1367 xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 2
1368 xref_index+=xref_index
1369 pdf_bytes+=str_tmp_obj
1370
1371 #OBJECT 3 : Page Tree (reference to pages of the catalogue)
1372 str_tmp_obj="3 0 obj\n<< /Type /Pages /Kids ["
1373 0.upto(@pageIndex-1) do|i|
1374 str_tmp_obj+=(((i+1)*3)+1).to_s+" 0 R\n"
1375 end
1376 str_tmp_obj+="] /Count "+@pageIndex.to_s+" >>\nendobj\n"
1377
1378 xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 3
1379 xref_index+=xref_index
1380 pdf_bytes+=str_tmp_obj
1381
1382 0.upto(@pageIndex-1) do|itr|
1383 width=@pages_data[itr][:width].to_s
1384 height=@pages_data[itr][:height].to_s
1385
1386 #OBJECT 4..7..10..n : Page config
1387 str_tmp_obj=(((itr+2)*3)-2).to_s+" 0 obj\n<<\n/Type /Page /Parent 3 0 R \n/MediaBox [ 0 0 "+width+" "+height+" ]\n/Resources <<\n/ProcSet [ /PDF ]\n/XObject <</R"+(itr+1).to_s+" "+((itr+2)*3).to_s+" 0 R>>\n>>\n/Contents [ "+(((itr+2)*3)-1).to_s+" 0 R ]\n>>\nendobj\n"
1388 xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 4,7,10,13,16...
1389 xref_index+=xref_index
1390 pdf_bytes+=str_tmp_obj
1391
1392
1393 #OBJECT 5...8...11...n : Page resource object (xobject resource that transforms the image)
1394 xref_list[xref_index]=calculate_xpos(pdf_bytes.length) #refenrece to obj 5,8,11,14,17...
1395 xref_index+=xref_index
1396 pdf_bytes+=get_xobj_resource(itr);
1397
1398 #OBJECT 6...9...12...n : Binary xobject of the page (image)
1399 img_BA=add_image_to_pdf(itr,@compress)