Guest User

Untitled

a guest
Sep 17th, 2013
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.59 KB | None | 0 0
  1. total_vertical = timedelta(hours=0, minutes=0)
  2.                            
  3.             cr.execute("SELECT enti.entidade, jobs.nr_job " \
  4.                 "FROM all_jobs AS jobs " \
  5.                 "JOIN jobsopen_entidades AS enti ON enti.id = jobs.entidade_id " \
  6.                 "JOIN all_services as servic on servic.job_id = jobs.id " \
  7.                 "WHERE servic.create_uid = %s AND " \
  8.                 "EXTRACT(MONTH FROM servic.date_service) = %s " \
  9.                 "GROUP BY 1,2",[5, 9])
  10.                
  11.             query_A = cr.fetchall()
  12.            
  13.             if query_A:
  14.                 for values_A in query_A:
  15.                     sheet.write(line_, 0, values_A[0], style_main)
  16.                     sheet.write(line_, 1, values_A[1], style_main)
  17.                     for i in range(1, 32):
  18.                    
  19.                         cr.execute("SELECT SUM(CAST(hour_end as time) - CAST(hour_begin as time)) AS time_ " \
  20.                         "FROM all_services AS servic " \
  21.                         "JOIN all_jobs AS jobs ON jobs.id = servic.job_id " \
  22.                         "WHERE servic.create_uid = %s AND " \
  23.                         "EXTRACT(MONTH FROM date_service) = %s AND " \
  24.                         "EXTRACT(DAY FROM date_service) = %s AND " \
  25.                         "jobs.nr_job = %s",[5, 9, i, values_A[1]])
  26.                        
  27.                         query_B = cr.fetchall()
  28.                         if query_B:
  29.                             for values_B in query_B:
  30.                                 current_value = str(values_B[0]);
  31.                                 if current_value != 'None':
  32.                                     hours_ = current_value.split(':')[0]
  33.                                     minutes_ = current_value.split(':')[1]
  34.                                     total_ = hours_ +':'+ minutes_
  35.  
  36.                                     sheet.write(line_, i + 1, total_, style_main)
  37.                                    
  38.                                     total_vertical += timedelta(hours=int(hours_), minutes=int(minutes_))
  39.                     sheet.write(line_, 33, str(total_vertical), style_main)
  40.                     line_ += 1 
  41.                     total_vertical = timedelta(hours=0, minutes=0) # Reset
Advertisement
Add Comment
Please, Sign In to add comment