-SProject.destroy_all 


%table.table
  -@result.each do |result|
    
    - s_project = SProject.new
    %tr
      %td
        =s_project.p_customer = PCustomer.where(:code => result["Bill-to Customer No_"]).first
      
      
        =s_project.p_number = result["No_"]
      
      %td
        =s_project.p_year = "20"+s_project.p_number[2..3].to_s
      
      %td  
        =s_project.p_month = s_project.p_number[4..5]
        
      %td
        =s_project.p_index = s_project.p_number[6..7]
      
      %td
        =s_project.name = result["Description"]
      
      %td
        =s_project.description = result["Description 2"]
      
      
      %td
        =s_project.nav_order_no_customer = result["Order No_ Customer"]
      
      %td
        =s_project.nav_main_project_no = result["Main Project"]
        
      %td
        =s_project.nav_project_status = result["Project Status"]
      
      
      %td
        =s_project.nav_project_type = result["Project Type"]
        
      
      %td
        =s_project.nav_estimate_no = result["Estimate No_"]
        
      %td
        =s_project.nav_site_production = result["Site Production"]
      
      
      
        
      %td
        =s_project.nav_creation_date = result["Creation Date"] if result["Creation Date"].to_s != "01/01/1753 00:00:00"
      
      %td
        =s_project.nav_starting_date = result["Starting Date"] if result["Starting Date"].to_s != "01/01/1753 00:00:00"
      
      %td
        =s_project.nav_ending_date = result["Ending Date"] if result["Ending Date"].to_s != "01/01/1753 00:00:00"
      
      %td
        =s_project.nav_last_modified_date = result["Last Date Modified"] if result["Last Date Modified"].to_s != "01/01/1753 00:00:00"
      
      %td
        =s_project.nav_technical_finished_date = result["Technical Finished Date"] if result["Technical Finished Date"].to_s != "01/01/1753 00:00:00"
      
      %td
        =s_project.nav_commission_principal_date = result["Commision Date Principal"] if result["Commision Date Principal"].to_s != "01/01/1753 00:00:00"
      
      %td
        =s_project.nav_last_invoice_date = result["Last Invoice date"] if result["Last Invoice date"].to_s != "01/01/1753 00:00:00"
      
      %td
        =s_project.nav_livraison_client_date = result["Date livraison client"].to_s if result["Date livraison client"] != "01/01/1753 00:00:00"
      
              
        
        
        
        

      %td
        =s_project.save
%table
  -SProject.all.each do |sp|
    -sp.created_at = sp.nav_creation_date if sp.nav_creation_date
    -if sp.nav_main_project_no != sp.p_number and SProject.where(:p_number => sp.nav_main_project_no).first
      %tr
        %td= sp.parent_id = SProject.where(:p_number => sp.nav_main_project_no).first.id
        
    -sp.save
      