Advertisement
PomozMi

Untitled

Aug 31st, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 122.25 KB | None | 0 0
  1. package info.androidhive.loginandregistration;
  2.  
  3. import android.app.AlertDialog;
  4. import android.app.DatePickerDialog;
  5. import android.app.ProgressDialog;
  6. import android.app.TimePickerDialog;
  7. import android.content.Intent;
  8. import android.graphics.Color;
  9. import android.graphics.Typeface;
  10. import android.os.Bundle;
  11. import android.support.v4.app.Fragment;
  12. import android.text.Html;
  13. import android.util.Log;
  14. import android.util.SparseBooleanArray;
  15. import android.view.LayoutInflater;
  16. import android.view.View;
  17. import android.view.ViewGroup;
  18. import android.widget.ArrayAdapter;
  19. import android.widget.Button;
  20. import android.widget.DatePicker;
  21. import android.widget.GridView;
  22. import android.widget.ImageButton;
  23. import android.widget.ListView;
  24. import android.widget.RadioGroup;
  25. import android.widget.TextView;
  26. import android.widget.TimePicker;
  27. import android.widget.Toast;
  28.  
  29. import com.android.volley.Request;
  30. import com.android.volley.Response;
  31. import com.android.volley.VolleyError;
  32. import com.android.volley.toolbox.StringRequest;
  33.  
  34. import org.json.JSONException;
  35. import org.json.JSONObject;
  36.  
  37. import java.text.ParseException;
  38. import java.text.SimpleDateFormat;
  39. import java.util.ArrayList;
  40. import java.util.Calendar;
  41. import java.util.Date;
  42. import java.util.HashMap;
  43. import java.util.List;
  44. import java.util.Map;
  45. import java.util.StringTokenizer;
  46.  
  47. import info.androidhive.loginandregistration.app.AppConfig;
  48. import info.androidhive.loginandregistration.app.AppController;
  49. import info.androidhive.loginandregistration.helper.SQLiteHandler;
  50.  
  51. /**
  52.  * Created by Karol on 2015-07-20.
  53.  */
  54.  
  55. public class SecondFragment extends Fragment {
  56.  
  57.     private static final String TAG =  SecondFragment.class.getSimpleName();
  58.  
  59.     private ProgressDialog pDialog;
  60.  
  61.     private SQLiteHandler db;
  62.  
  63.     // ustawia date
  64.     private Button podsumowanie;
  65.  
  66.     public static Button pracownicy;
  67.  
  68.     private GridView gridView;
  69.  
  70.     public static TextView textViewZlecenieID2;
  71.  
  72.  
  73.     // generuj rekordy raportu
  74.     private Button podglad;
  75.     private Button wyslij;
  76.  
  77.     RadioGroup radioGroup;
  78.     ListView listViewOsoby;
  79.     //
  80.  
  81.  
  82.     private Button dojazd;
  83.     private Button praca;
  84.     private Button powrot;
  85.     private Button przerwa;
  86.     private Button koszt;
  87.  
  88.     private static Button dojazd_od;
  89.     private static Button dojazd_do;
  90.     private static Button praca_od;
  91.     private static Button praca_do;
  92.     private static Button powrot_od;
  93.     private static Button powrot_do;
  94.     private static Button lunch_od;
  95.     private static Button lunch_do;
  96.  
  97.  
  98.     public static String dojazd_od_time;
  99.     public static String dojazd_do_time;
  100.     public static String praca_od_time;
  101.     public static String praca_do_time;
  102.     public static String powrot_od_time;
  103.     public static String powrot_do_time;
  104.     public static String lunch_od_time;
  105.     public static String lunch_do_time;
  106.     public ImageButton imageRefresh;
  107.     public ImageButton podgladobok;
  108.  
  109.  
  110.  
  111.     public static int countList=0;
  112.     public static int countinGrid=0;
  113.  
  114.  
  115.   //  public  static HashMap<Integer, boolean> checkMyList;
  116.  
  117.     static final Raport raport = new Raport();
  118.  
  119.     private static String ID_wybrani = "";
  120.     public static Button help;
  121.  
  122.     @Override
  123.     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  124.         View v = inflater.inflate(R.layout.activity_second_fragment, container, false);
  125.  
  126.         textViewZlecenieID2 = (TextView) v.findViewById(R.id.textViewZlecenieID2);
  127.  
  128.         // SQLite database handler
  129.         db = new SQLiteHandler(getActivity());
  130.  
  131.         //set time and etc.
  132.  
  133.         dojazd_od   = (Button) v.findViewById(R.id.btn_dojazd_od);
  134.         dojazd_do   = (Button) v.findViewById(R.id.btn_dojazd_do);
  135.         praca_od    = (Button) v.findViewById(R.id.btn_praca_od);
  136.         praca_do    = (Button) v.findViewById(R.id.btn_praca_do);
  137.         powrot_od   = (Button) v.findViewById(R.id.btn_powrot_od);
  138.         powrot_do   = (Button) v.findViewById(R.id.btn_powrot_do);
  139.         lunch_od    = (Button) v.findViewById(R.id.btn_lunch_od);
  140.         lunch_do    = (Button) v.findViewById(R.id.btn_lunch_do);
  141.  
  142.         dojazd = (Button) v.findViewById(R.id.textDojazd);
  143.         praca = (Button) v.findViewById(R.id.textPraca);
  144.         przerwa = (Button)v.findViewById(R.id.textPrzerwa);
  145.         powrot = (Button) v.findViewById(R.id.textPowrot);
  146.         koszt = (Button) v.findViewById(R.id.textKoszty);
  147.  
  148.         podglad = (Button) v.findViewById(R.id.btnRaport_ok_second_frag);
  149.  
  150.  
  151.         wyslij = (Button) v.findViewById(R.id.btnSend);
  152.         podsumowanie = (Button) v.findViewById(R.id.btnPodsumowaniesecond_frag);
  153.  
  154.         pracownicy = (Button) v.findViewById(R.id.textPracownicy);
  155.         listViewOsoby = (ListView) v.findViewById(R.id.listViewOsoby);
  156.         listViewOsoby.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
  157.  
  158.         help = (Button) v.findViewById(R.id.help);
  159.         gridView = (GridView) v.findViewById(R.id.gridView);
  160.  
  161.         //Typeface type = Typeface.createFromAsset(getActivity().getAssets(),"fonts/lucon.ttf");
  162.  
  163.         imageRefresh = (ImageButton) v.findViewById(R.id.imagerefresh);
  164.  
  165.         imageRefresh.setOnClickListener(new View.OnClickListener() {
  166.             @Override
  167.             public void onClick(View v) {
  168.                 showGridView();
  169.                 Toast.makeText(getActivity(),"showGridView()",Toast.LENGTH_SHORT).show();
  170.             }
  171.         });
  172.  
  173.         podgladobok = (ImageButton) v.findViewById(R.id.podgladobok);
  174.  
  175.         podgladobok.setOnClickListener(new View.OnClickListener() {
  176.             @Override
  177.             public void onClick(View v) {
  178.  
  179.                 Intent _intent = new Intent(getActivity(), Podglad.class);
  180.                 startActivity(_intent);
  181.  
  182.  
  183.  
  184.             }
  185.         });
  186.  
  187.                 setTime();
  188.         clear();
  189.         clearline();
  190.         // save and go to the next page
  191.         try{
  192.             //buttonPodglad();
  193.  
  194.         }catch(Exception e){
  195.             new AlertDialog.Builder(getActivity())
  196.                     .setTitle("Ups")
  197.                     .setMessage("Coś poszło nie tak, odśwież kartę")
  198.                     .show();
  199.  
  200.         }
  201.  
  202.         setDate_setID();
  203.         _pracownicy();
  204.  
  205.         try {
  206.             listViewOsoby(); // ID_wybrani = ""   - nikt nie wybrany
  207.         } catch (ParseException e) {
  208.             e.printStackTrace();
  209.         }
  210.         onclickListViewOsoby();
  211.  
  212.  
  213.  
  214.  
  215.  
  216.         help.setOnClickListener(new View.OnClickListener() {
  217.             @Override
  218.             public void onClick(View v) {
  219.  
  220.                 showGridView();
  221.             }
  222.         });
  223.  
  224.         return v;
  225.     }
  226.  
  227.     public void _pracownicy(){
  228.     pracownicy.setOnClickListener(new View.OnClickListener() {
  229.         @Override
  230.         public void onClick(View v) {
  231.             try {
  232.                 listViewOsoby();
  233.             } catch (ParseException e) {
  234.                 e.printStackTrace();
  235.             }
  236.  
  237.             for (int i = 0; i < countList; i++) {
  238.                 listViewOsoby.setItemChecked(i, true);
  239.             }
  240.  
  241.             showGoodTable();
  242.         }
  243.     });
  244.  
  245.     pracownicy.setOnLongClickListener(new View.OnLongClickListener() {
  246.         @Override
  247.         public boolean onLongClick(View v) {
  248.             /////////
  249.  
  250.             Integer ilezazanaczonych = 0;
  251.  
  252.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  253.  
  254.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  255.             {
  256.                 if (checked.get(z)) {
  257.             ilezazanaczonych++;
  258.                 }
  259.             }
  260.             if(ilezazanaczonych > ( countList / 2 ) ){
  261.                 try {
  262.                     listViewOsoby();
  263.                 } catch (ParseException e) {
  264.                     e.printStackTrace();
  265.                 }
  266.             } else {
  267.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++) {
  268.                     listViewOsoby.setItemChecked(z, true);
  269.                     Log.d(TAG, "z = " + z);
  270.                 }
  271.             }
  272.             showGoodTable();
  273.             return true;
  274.  
  275.         }
  276.     });
  277. }
  278.  
  279.     private void onclickListViewOsoby(){
  280.  
  281.         listViewOsoby.setOnLongClickListener(new View.OnLongClickListener() {
  282.             @Override
  283.             public boolean onLongClick(View v) {
  284.  
  285.  
  286.                 return true;
  287.             }
  288.         });
  289.  
  290.     }
  291.  
  292.     private void warnigs(){
  293.         if ((raport.dojazd_od != null && raport.dojazd_do == null || raport.dojazd_do != null && raport.dojazd_od == null) ||
  294.                 (raport.praca_od != null && raport.praca_do == null || raport.praca_do != null && raport.praca_od == null) ||
  295.                 (raport.powrot_od != null && raport.powrot_do == null || raport.powrot_do != null && raport.powrot_od == null) ||
  296.                 (raport.lunch_od != null && raport.lunch_do == null || raport.lunch_do != null && raport.lunch_od == null)) {
  297.             new AlertDialog.Builder(getActivity())
  298.                     .setTitle(getResources().getString(R.string.giveMeMoreTitle))
  299.                     .setMessage(getResources().getString(R.string.giveMeMore))
  300.                     .setNegativeButton(getResources().getString(R.string.giveMeMoreOk), null)
  301.                     .show();
  302.             return;
  303.         }
  304.  
  305.         String tmp = "";
  306.  
  307.         if(raport.dojazd_od != null && raport.dojazd_do != null){
  308.  
  309.             if( moreThanOneDay(raport.dojazd_od, raport.dojazd_do)) {
  310.                 raport.moreThanOneDay_dojazd = true;
  311.                 if(tmp == ""){
  312.                     tmp = "\"" + getResources().getString(R.string.commuting_to_name)+ "\"" ;
  313.                 }else{
  314.                     tmp +=" , \"" + getResources().getString(R.string.commuting_to_name)+ "\"" ;
  315.                 }
  316.             }
  317.         }
  318.         if(raport.praca_od != null && raport.praca_do != null) {
  319.  
  320.             if (moreThanOneDay(raport.praca_od, raport.praca_do)) {
  321.                 raport.moreThanOneDay_praca = true;
  322.                 if(tmp == ""){
  323.                     tmp ="\"" +  getResources().getString(R.string.hours_name)+ "\"" ;
  324.                 }else{
  325.                     tmp +=" , \"" + getResources().getString(R.string.hours_name)+ "\"" ;
  326.                 }
  327.             }
  328.         }
  329.  
  330.         if(raport.powrot_od != null && raport.powrot_do != null){
  331.             if( moreThanOneDay(raport.powrot_od, raport.powrot_do)){
  332.                 raport.moreThanOneDay_powrot = true;
  333.                 if(tmp == ""){
  334.                     tmp = "\"" +  getResources().getString(R.string.commuting_from_name) + "\""  ;
  335.                 }else{
  336.                     tmp +=" , \"" + getResources().getString(R.string.commuting_from_name)+ "\"" ;
  337.                 }
  338.             }
  339.         }
  340.  
  341.         if(raport.lunch_od != null && raport.lunch_do != null) {
  342.             if (moreThanOneDay(raport.lunch_od, raport.lunch_do)) {
  343.                 raport.moreThanOneDay_przerwa = true;
  344.                 if(tmp == ""){
  345.                     tmp = "\"" + getResources().getString(R.string.break_name)+ "\"" ;
  346.                 }else{
  347.                     tmp +=" , \"" + getResources().getString(R.string.break_name)+ "\"" ;
  348.                 }
  349.             }
  350.         }
  351.  
  352.         if(raport.moreThanOneDay_przerwa == true ||raport.moreThanOneDay_praca == true ||
  353.                 raport.moreThanOneDay_dojazd == true || raport.moreThanOneDay_powrot == true ) {
  354.  
  355.             new AlertDialog.Builder(getActivity())
  356.                     .setTitle(getResources().getString(R.string.moreThanOneDayTitle))
  357.                     .setMessage((getResources().getString(R.string.moreThanOneDay)) + " "
  358.                             + tmp + (getResources().getString(R.string.moreThanOneDay2)) + " "
  359.                             + raport.getRaportowanydzien_pomocnicze() + ". "
  360.                             + (getResources().getString(R.string.moreThanOneDay3)))
  361.                     .setNegativeButton(getResources().getString(R.string.moreThanOneDayCancel), null)
  362.                     .setPositiveButton((getResources().getString(R.string.moreThanOneDayOk)+ " " + raport.getRaportowanydzien_pomocnicze() ), null)
  363.                     .show();
  364.  
  365.             return;
  366.         }
  367.         ////////////////////////////////
  368.         boolean flag = false;
  369.         String thisnotstartafter = "";
  370.         if(notstartAfter(raport.dojazd_do, raport.praca_od)) {
  371.             thisnotstartafter = getResources().getString(R.string.commuting_to_name)+" - " + getResources().getString(R.string.hours_name) ;
  372.             flag = true;
  373.         }
  374.         if(notstartAfter(raport.praca_do, raport.powrot_od)){
  375.                 if(thisnotstartafter!= "" ){
  376.                     thisnotstartafter += " , " + getResources().getString(R.string.hours_name)+" - " + getResources().getString(R.string.commuting_from_name);
  377.                 }else {
  378.                     thisnotstartafter = getResources().getString(R.string.hours_name)+" - " + getResources().getString(R.string.commuting_from_name);
  379.                 }
  380.             flag = true;
  381.         }
  382.         if (flag){
  383.             new AlertDialog.Builder(getActivity())
  384.                     .setTitle(getResources().getString(R.string.NotAfterTitle))
  385.                     .setMessage((getResources().getString(R.string.NotAfter)) + " "+ thisnotstartafter )
  386.                     .setNegativeButton(getResources().getString(R.string.NotAfterCancel), null)
  387.                     .setPositiveButton((getResources().getString(R.string.NotAfterOk)), null)
  388.                     .show();
  389.             return ;
  390.         }
  391.     }
  392.  
  393.     private void zapisz() {
  394.  
  395.         if(raport.dojazd_od != null && raport.dojazd_do != null){
  396.             Log.d(TAG, "raport.dojazd = true;");
  397.             raport.dojazd = true;
  398.         }
  399.         if(raport.praca_od != null && raport.praca_do != null) {
  400.             raport.praca = true;
  401.             Log.d(TAG, "raport.praca = true;");
  402.         }
  403.         if(raport.powrot_od != null && raport.powrot_do != null){
  404.             raport.powrot = true;
  405.             Log.d(TAG, "raport.powrot = true;");
  406.         }
  407.         if(raport.lunch_od != null && raport.lunch_do != null) {
  408.             raport.przerwa = true;
  409.             Log.d(TAG, "raport.przerwa = true;");
  410.         }
  411.  
  412.         Calendar mcurrentTime = Calendar.getInstance();
  413.         Integer day = mcurrentTime.get(Calendar.DATE);
  414.         Integer month = mcurrentTime.get(Calendar.MONTH);
  415.         Integer year = mcurrentTime.get(Calendar.YEAR);
  416.         Integer hour = mcurrentTime.get(Calendar.HOUR);
  417.         Integer minn = mcurrentTime.get(Calendar.MINUTE);
  418.  
  419.         String now = year.toString() + "-" + String.format("%02d", month + 1) + "-" + String.format("%02d", day) + " "
  420.                 + String.format("%02d", hour) + ":" + String.format("%02d", minn) + ":00";
  421.  
  422.         //              auto strzałka          pracownik            auto strzałka       kawa
  423.         //   daje+="         \uD83D\uDE98➝          \uD83D\uDC77           \uD83D\uDE98↩         ☕ \n";
  424.         SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  425.  
  426.         for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  427.         {
  428.             if (checked.get(z)){
  429.                 Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  430.  
  431.                 String imie = "";
  432.                 String nazwisko = "";
  433.                 String nrEwidencyjny = "";
  434.  
  435.                 String ID = "";
  436.  
  437.                 String _str = listViewOsoby.getAdapter().getItem(z).toString();
  438.                 StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  439.                 while (str.hasMoreTokens()){
  440.                     imie = str.nextElement().toString();
  441.                     nazwisko = str.nextElement().toString();
  442.                     nrEwidencyjny = str.nextElement().toString();
  443.                     Log.d(TAG, "imie = " + imie);
  444.                     Log.d(TAG, "nazwisko = " + nazwisko);
  445.                     Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  446.                     List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  447.                     for (PracownikZlecenieInastalacyjne curr : wszystko) {
  448.                         if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  449.                             ID = curr.getPr_Id().toString();}}
  450.                 }
  451.                 if (raport.dojazd)
  452.                 {
  453.                     RaportRow raportRow = new RaportRow();
  454.                     raportRow.setRp_TypOperacji("dd");
  455.                     raportRow.setRp_IdPracownik(Integer.parseInt(ID));
  456.                     raportRow.setRp_IdZlecenieInstalacyjne(raport.getZlecenieInstalacyjneID());
  457.                     raportRow.setRp_DataOd(raport.getDojazd_od());
  458.                     raportRow.setRp_DataDo(raport.getDojazd_do());
  459.                     raportRow.setRp_CzasTrwania(czastrwania(raport.getDojazd_od(), raport.getDojazd_do()));
  460.                     raportRow.setRp_CzasRaportowania(now);
  461.  
  462.                     db.deleteSimilarRaportRow(raportRow);
  463.                     db.addRaport(raportRow);
  464.                     Log.d(TAG, "db.addRaport dd:"+ raportRow.help() );
  465.                 }
  466.  
  467.                 if (raport.praca) {
  468.                     RaportRow raportRow = new RaportRow();
  469.                     raportRow.setRp_TypOperacji("pr");
  470.                     raportRow.setRp_IdPracownik(Integer.parseInt(ID));
  471.                     raportRow.setRp_IdZlecenieInstalacyjne(raport.getZlecenieInstalacyjneID());
  472.                     raportRow.setRp_DataOd(raport.getPraca_od());
  473.                     raportRow.setRp_DataDo(raport.getPraca_do());
  474.                     raportRow.setRp_CzasTrwania(czastrwania(raport.getPraca_od(), raport.getPraca_do()));
  475.                     raportRow.setRp_CzasRaportowania(now);
  476.  
  477.                     db.deleteSimilarRaportRow(raportRow);
  478.                     db.addRaport(raportRow);
  479.                     Log.d(TAG, "db.addRaport pr:" + raportRow.help());
  480.                 }
  481.  
  482.                 if (raport.powrot) {
  483.                     RaportRow raportRow = new RaportRow();
  484.                     raportRow.setRp_TypOperacji("dz");
  485.                     raportRow.setRp_IdPracownik(Integer.parseInt(ID));
  486.                     raportRow.setRp_IdZlecenieInstalacyjne(raport.getZlecenieInstalacyjneID());
  487.                     raportRow.setRp_DataOd(raport.getPowrot_od());
  488.                     raportRow.setRp_DataDo(raport.getPowrot_do());
  489.                     raportRow.setRp_CzasTrwania(czastrwania(raport.getPowrot_od(), raport.getPowrot_do()));
  490.                     raportRow.setRp_CzasRaportowania(now);
  491.  
  492.                     db.deleteSimilarRaportRow(raportRow);
  493.                     db.addRaport(raportRow);
  494.                     Log.d(TAG, "db.addRaport dz:" + raportRow.help());
  495.                 }
  496.  
  497.                 if (raport.przerwa) {
  498.                     RaportRow raportRow = new RaportRow();
  499.                     raportRow.setRp_TypOperacji("pz");
  500.                     raportRow.setRp_IdPracownik(Integer.parseInt(ID));
  501.                     raportRow.setRp_IdZlecenieInstalacyjne(raport.getZlecenieInstalacyjneID());
  502.                     raportRow.setRp_DataOd(raport.getLunch_od());
  503.                     raportRow.setRp_DataDo(raport.getLunch_do());
  504.                     raportRow.setRp_CzasTrwania(czastrwania(raport.getLunch_od(), raport.getLunch_do()));
  505.                     raportRow.setRp_CzasRaportowania(now);
  506.  
  507.                     db.deleteSimilarRaportRow(raportRow);
  508.                     db.addRaport(raportRow);
  509.                     Log.d(TAG, "db.addRaport pz:" + raportRow.help() );
  510.                 }
  511.             }
  512.         }
  513.     }
  514.  
  515.     private void showGoodTable(){
  516.  
  517.         Integer countThis = 0;
  518.  
  519.         if(!((lunch_od.getText() == "" && lunch_do.getText()!= "" )||( lunch_od.getText() != "" && lunch_do.getText() == "" )) ){
  520.             lunch_od.setText("");
  521.             lunch_do.setText("");
  522.         }
  523.         if(!((dojazd_od.getText() == "" &&dojazd_do.getText()!="" )||( dojazd_od.getText() != "" && dojazd_do.getText() == "" )) ){
  524.             dojazd_od.setText("");
  525.             dojazd_do.setText("");
  526.         }
  527.         if(!((praca_od.getText() == "" && praca_do.getText()!="" )||( praca_od.getText() != "" && praca_do.getText() == "" )) ){
  528.             praca_od.setText("");
  529.             praca_do.setText("");
  530.         }
  531.         if(!((powrot_od.getText() == "" && powrot_do.getText()!= "" )||( powrot_od.getText() != "" && powrot_do.getText() == "" )) ){
  532.             powrot_od.setText("");
  533.             powrot_do.setText("");
  534.         }
  535.  
  536.  
  537.         String dojazd = "";
  538.         String praca = "";
  539.         String powrot= "";
  540.         String przerwa= "";
  541.         String dojazd_curr  = "";
  542.         String praca_curr   = "";
  543.         String powrot_curr  = "";
  544.         String przerwa_curr = "";
  545.  
  546.  
  547.  
  548.         SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  549.         for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++) {
  550.             if (checked.get(z)) {
  551.                 String nrEwidencyjny = "";
  552.                 String ID = "";
  553.                 String _str = listViewOsoby.getAdapter().getItem(z).toString();
  554.  
  555.                 StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  556.                 while (str.hasMoreTokens()) {
  557.                     nrEwidencyjny = str.nextElement().toString();//zle
  558.                     nrEwidencyjny = str.nextElement().toString();//zle
  559.                     nrEwidencyjny = str.nextElement().toString();//ok
  560.                 }
  561.                 List<RaportRow> raportRowList = db.getAllRaport();
  562.                 List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  563.  
  564.                 for (PracownikZlecenieInastalacyjne curr : wszystko) {
  565.                     if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  566.                         ID = curr.getPr_Id().toString();
  567.                     }
  568.                 }
  569.  
  570.                 for (RaportRow tmp : raportRowList) {
  571.                     if (tmp.getRp_IdPracownik().equals(Integer.parseInt(ID))) {
  572.                         if (tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))) {
  573.                             if (tmp.getRp_IdZlecenieInstalacyjne().equals(Raport.getZlecenieInstalacyjneID())) {
  574.                                 if (tmp.getRp_TypOperacji().equals("dd")) {
  575.  
  576.                                     if(!Raport.blokadadojazd) {
  577.                                         String czas1 = tmp.getRp_DataOd();
  578.                                         StringTokenizer _from = new StringTokenizer(czas1, " : ");
  579.                                         String data = _from.nextElement().toString();
  580.                                         String HH1 = _from.nextElement().toString();
  581.                                         String MM1 = _from.nextElement().toString();
  582.  
  583.                                         String czas2 = tmp.getRp_DataDo();
  584.                                         StringTokenizer _to = new StringTokenizer(czas2, " : ");
  585.                                         String data2 = _to.nextElement().toString();
  586.                                         String HH2 = _to.nextElement().toString();
  587.                                         String MM2 = _to.nextElement().toString();
  588.  
  589.                                         dojazd = HH1 + ":" + MM1 + "-" + HH2 + ":" + MM2;
  590.  
  591.                                         if (countThis == 0) {
  592.                                             dojazd_od.setText(HH1 + ":" + MM1);
  593.                                             dojazd_do.setText(HH2 + ":" + MM2);
  594.  
  595.                                             dojazd_curr = dojazd;
  596.                                         } else {
  597.                                             if (!(dojazd_curr.equals(dojazd))) {
  598.                                                 dojazd_od.setText("XX-XX");
  599.                                                 dojazd_do.setText("XX-XX");
  600.                                             }
  601.                                         }
  602.  
  603.                                     }
  604.                                 } else if (tmp.getRp_TypOperacji().equals("pr")) {
  605.                                     if(!Raport.blokadapraca) {
  606.                                         String czas1 = tmp.getRp_DataOd();
  607.                                         StringTokenizer _from = new StringTokenizer(czas1, " : ");
  608.                                         String data = _from.nextElement().toString();
  609.                                         String HH1 = _from.nextElement().toString();
  610.                                         String MM1 = _from.nextElement().toString();
  611.                                         String czas2 = tmp.getRp_DataDo();
  612.                                         StringTokenizer _to = new StringTokenizer(czas2, " : ");
  613.                                         String data2 = _to.nextElement().toString();
  614.                                         String HH2 = _to.nextElement().toString();
  615.                                         String MM2 = _to.nextElement().toString();
  616.                                         praca = HH1 + ":" + MM1 + "-" + HH2 + ":" + MM2;
  617.                                         if (countThis == 0) {
  618.                                             praca_od.setText(HH1 + ":" + MM1);
  619.                                             praca_do.setText(HH2 + ":" + MM2);
  620.                                             praca_curr = praca;
  621.                                         } else {
  622.  
  623.                                             if (!(praca_curr.equals(praca))) {
  624.  
  625.                                                 praca_od.setText("XX-XX");
  626.                                                 praca_do.setText("XX-XX");
  627.                                             }
  628.                                         }
  629.  
  630.                                     }
  631.                                 } else if (tmp.getRp_TypOperacji().equals("pz")) {
  632.  
  633.                                     if(!Raport.blokadaprzerwa) {
  634.                                         String czas1 = tmp.getRp_DataOd();
  635.                                         StringTokenizer _from = new StringTokenizer(czas1, " : ");
  636.                                         String data = _from.nextElement().toString();
  637.                                         String HH1 = _from.nextElement().toString();
  638.                                         String MM1 = _from.nextElement().toString();
  639.                                         String czas2 = tmp.getRp_DataDo();
  640.                                         StringTokenizer _to = new StringTokenizer(czas2, " : ");
  641.                                         String data2 = _to.nextElement().toString();
  642.                                         String HH2 = _to.nextElement().toString();
  643.                                         String MM2 = _to.nextElement().toString();
  644.                                         przerwa = HH1 + ":" + MM1 + "-" + HH2 + ":" + MM2;
  645.                                         if (countThis == 0) {
  646.  
  647.                                             lunch_od.setText(HH1 + ":" + MM1);
  648.                                             lunch_do.setText(HH2 + ":" + MM2);
  649.                                             przerwa_curr = przerwa;
  650.                                         } else {
  651.                                             if (!(przerwa_curr.equals(przerwa))) {
  652.  
  653.                                                 lunch_od.setText("XX-XX");
  654.                                                 lunch_do.setText("XX-XX");
  655.                                             }
  656.                                         }
  657.                                     }
  658.                                 } else if (tmp.getRp_TypOperacji().equals("dz")) {
  659.                                     if(!Raport.blokadapowrot) {
  660.                                         String czas1 = tmp.getRp_DataOd();
  661.                                         StringTokenizer _from = new StringTokenizer(czas1, " : ");
  662.                                         String data = _from.nextElement().toString();
  663.                                         String HH1 = _from.nextElement().toString();
  664.                                         String MM1 = _from.nextElement().toString();
  665.                                         String czas2 = tmp.getRp_DataDo();
  666.                                         StringTokenizer _to = new StringTokenizer(czas2, " : ");
  667.                                         String data2 = _to.nextElement().toString();
  668.                                         String HH2 = _to.nextElement().toString();
  669.                                         String MM2 = _to.nextElement().toString();
  670.                                         powrot = HH1 + ":" + MM1 + "-" + HH2 + ":" + MM2;
  671.                                         if (countThis == 0) {
  672.                                             powrot_od.setText(HH1 + ":" + MM1);
  673.                                             powrot_do.setText(HH2 + ":" + MM2);
  674.                                             powrot_curr = powrot;
  675.                                         } else {
  676.                                             if (!(powrot_curr.equals(powrot))) {
  677.                                                 powrot_od.setText("XX-XX");
  678.                                                 powrot_do.setText("XX-XX");
  679.                                             }
  680.                                         }
  681.                                     }
  682.                                 } else if (tmp.getRp_TypOperacji().equals("kd")) {
  683.                                     Log.d(TAG, "_________TEST  koszt dojazdu  ");
  684.                                 } else if (tmp.getRp_TypOperacji().equals("kh")) {
  685.                                     Log.d(TAG, "_________TEST koszt hotelu ");
  686.                                 } else if (tmp.getRp_TypOperacji().equals("ki")) {
  687.                                     Log.d(TAG, "_________TEST  koszt inny  ");
  688.                                 } else if (tmp.getRp_TypOperacji().equals("kp")) {
  689.                                     Log.d(TAG, "_________TEST km prywatne  ");
  690.                                 } else if (tmp.getRp_TypOperacji().equals("ki")) {
  691.                                     Log.d(TAG, "_________TEST km flexlink  ");
  692.                                 }
  693.                             }
  694.                         }
  695.                     }
  696.                 }
  697.                 countThis++;
  698.             }
  699.         }
  700.     }
  701.  
  702.     private void showGridView() {
  703.  
  704.         showGoodTable();
  705.  
  706.  
  707. //
  708. //        String typ_operacji;
  709. //        typ_operacji = "\uD83D\uDE98➝";     //dojazd
  710. //        typ_operacji = "\uD83D\uDC77";       //praca
  711. //        typ_operacji = "\uD83D\uDE98↩";     //powrot
  712. //        typ_operacji = "☕";                 //kawa ikona
  713.         List elements = new ArrayList();
  714.         elements.add("Nr ewidencyjny ");
  715.         elements.add("🚘➝");
  716.         elements.add("👷");
  717.         elements.add("🚘↩");
  718.         elements.add("☕");
  719.  
  720.         for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++) {
  721.             String imie = "";
  722.             String nazwisko = "";
  723.             String nrEwidencyjny = "";
  724.             String ID = "";
  725.             String dojazd = "";
  726.             String praca = "";
  727.             String powrot= "";
  728.             String przerwa= "";
  729.             String dojazd_curr  = "";
  730.             String praca_curr   = "";
  731.             String powrot_curr  = "";
  732.             String przerwa_curr = "";
  733.             String _str = listViewOsoby.getAdapter().getItem(z).toString();
  734.  
  735.                 StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  736.                 while (str.hasMoreTokens()) {
  737.                     imie = str.nextElement().toString();
  738.                     nazwisko = str.nextElement().toString();
  739.                     nrEwidencyjny = str.nextElement().toString();
  740.                 }
  741.                     List<RaportRow> raportRowList= db.getAllRaport();
  742.                     List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  743.  
  744.                     for (PracownikZlecenieInastalacyjne curr : wszystko) {
  745.                         if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  746. // NR EWIDENCYJNY
  747. // podaje numer osooby z listy ale chce miec wiecej
  748.  
  749.                             ID = curr.getPr_Id().toString();
  750.                             //break;
  751.                         }
  752.                     }
  753.  
  754.  
  755.                     for (RaportRow tmp : raportRowList) {
  756.                         if( tmp.getRp_IdPracownik().equals(Integer.parseInt(ID))) {
  757. // ID pracownika z listy           // .       |
  758.                                   if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  759.                                 //or
  760.                             if (tmp.getRp_IdZlecenieInstalacyjne().equals(Raport.getZlecenieInstalacyjneID())) {
  761. // ID zlecenia
  762.                                 if (tmp.getRp_TypOperacji().equals("dd")) {
  763.                                     if(tmp.getRp_Wyslany() == 1){
  764.                                         Log.e(TAG, "wyslany");
  765.  
  766.                                     }
  767.  
  768.                                     String czas1 = tmp.getRp_DataOd();
  769.                                     StringTokenizer _from = new StringTokenizer(czas1, " : ");
  770.                                     String data = _from.nextElement().toString();
  771.                                     String HH1 = _from.nextElement().toString();
  772.                                     String MM1 = _from.nextElement().toString();
  773.  
  774.                                     String czas2 = tmp.getRp_DataDo();
  775.                                     StringTokenizer _to = new StringTokenizer(czas2, " : ");
  776.                                     String data2 = _to.nextElement().toString();
  777.                                     String HH2 = _to.nextElement().toString();
  778.                                     String MM2 = _to.nextElement().toString();
  779.                                     dojazd = HH1 + ":" + MM1 + "-" + HH2 + ":" + MM2;
  780.                                 } else if (tmp.getRp_TypOperacji().equals("pr")) {
  781.                                     if(tmp.getRp_Wyslany() == 1){
  782.                                         Log.e(TAG, "wyslany");
  783.  
  784.                                     }
  785.                                     String czas1 = tmp.getRp_DataOd();
  786.                                     StringTokenizer _from = new StringTokenizer(czas1, " : ");
  787.                                     String data = _from.nextElement().toString();
  788.                                     String HH1 = _from.nextElement().toString();
  789.                                     String MM1 = _from.nextElement().toString();
  790.                                     String czas2 = tmp.getRp_DataDo();
  791.                                     StringTokenizer _to = new StringTokenizer(czas2, " : ");
  792.                                     String data2 = _to.nextElement().toString();
  793.                                     String HH2 = _to.nextElement().toString();
  794.                                     String MM2 = _to.nextElement().toString();
  795.                                     praca = HH1 + ":" + MM1 + "-" + HH2 + ":" + MM2;
  796.  
  797.                                 } else if (tmp.getRp_TypOperacji().equals("pz")) {
  798.                                     if(tmp.getRp_Wyslany() == 1){
  799.                                         Log.e(TAG, "wyslany");
  800.  
  801.                                     }
  802.  
  803.                                     String czas1 = tmp.getRp_DataOd();
  804.                                     StringTokenizer _from = new StringTokenizer(czas1, " : ");
  805.                                     String data = _from.nextElement().toString();
  806.                                     String HH1 = _from.nextElement().toString();
  807.                                     String MM1 = _from.nextElement().toString();
  808.                                     String czas2 = tmp.getRp_DataDo();
  809.                                     StringTokenizer _to = new StringTokenizer(czas2, " : ");
  810.                                     String data2 = _to.nextElement().toString();
  811.                                     String HH2 = _to.nextElement().toString();
  812.                                     String MM2 = _to.nextElement().toString();
  813.                                     przerwa = HH1 + ":" + MM1 + "-" + HH2 + ":" + MM2;
  814.  
  815.  
  816.                                 } else if (tmp.getRp_TypOperacji().equals("dz")) {
  817.                                     if(tmp.getRp_Wyslany() == 1){
  818.                                         Log.e(TAG, "wyslany");
  819.  
  820.                                     }
  821.                                     String czas1 = tmp.getRp_DataOd();
  822.                                     StringTokenizer _from = new StringTokenizer(czas1, " : ");
  823.                                     String data = _from.nextElement().toString();
  824.                                     String HH1 = _from.nextElement().toString();
  825.                                     String MM1 = _from.nextElement().toString();
  826.                                     String czas2 = tmp.getRp_DataDo();
  827.                                     StringTokenizer _to = new StringTokenizer(czas2, " : ");
  828.                                     String data2 = _to.nextElement().toString();
  829.                                     String HH2 = _to.nextElement().toString();
  830.                                     String MM2 = _to.nextElement().toString();
  831.                                     powrot = HH1 + ":" + MM1 + "-" + HH2 + ":" + MM2;
  832.  
  833.  
  834.                                 } else if (tmp.getRp_TypOperacji().equals("kd")) {
  835.                                     Log.e(TAG, "_________TEST  koszt dojazdu  ");
  836.                                 } else if (tmp.getRp_TypOperacji().equals("kh")) {
  837.                                     Log.e(TAG, "_________TEST koszt hotelu ");
  838.                                 } else if (tmp.getRp_TypOperacji().equals("ki")) {
  839.                                     Log.e(TAG, "_________TEST  koszt inny  ");
  840.                                 } else if (tmp.getRp_TypOperacji().equals("kp")) {
  841.                                     Log.e(TAG, "_________TEST km prywatne  ");
  842.                                 } else if (tmp.getRp_TypOperacji().equals("ki")) {
  843.                                     Log.e(TAG, "_________TEST km flexlink  ");
  844.                                 }
  845.                             }
  846.                                   }
  847.                         }
  848.                         countinGrid++;
  849.                     }
  850.             elements.add(nrEwidencyjny);
  851.             elements.add(dojazd);
  852.             elements.add(praca);
  853.             elements.add(powrot);
  854.             elements.add(przerwa);
  855.         }
  856.         // Creating adapter for spinner
  857.         ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_gallery_item, elements);
  858.  
  859.         gridView.setAdapter(dataAdapter);
  860.  
  861.     }
  862.  
  863.     public static void clearALL(){
  864.  
  865.     Raport r = new Raport();
  866.  
  867.     r.dojazd = false;
  868.     r.praca = false;
  869.     r.przerwa = false;
  870.     r.powrot = false;
  871.  
  872.  
  873.     dojazd_od_time = String.format("");
  874.     dojazd_od.setText(dojazd_od_time);
  875.     dojazd_do.setText(dojazd_od_time);
  876.     praca_do.setText(dojazd_od_time);
  877.     praca_od.setText(dojazd_od_time);
  878.     powrot_od.setText(dojazd_od_time);
  879.     powrot_do.setText(dojazd_od_time);
  880.     lunch_od.setText(dojazd_od_time);
  881.     lunch_do.setText(dojazd_od_time);
  882.  
  883.     raport.setDojazd_od(null);
  884.     raport.setDojazd_do(null);
  885.     raport.setPraca_od(null);
  886.     raport.setPraca_do(null);
  887.     raport.setPowrot_od(null);
  888.     raport.setPowrot_do(null);
  889.     raport.setLunch_od(null);
  890.     raport.setLunch_do(null);
  891.  
  892.  
  893.  
  894. }
  895.  
  896.     private boolean notstartAfter(String from, String to){
  897.         if(from == null || to == null){return false;}
  898.         StringTokenizer _from = new StringTokenizer(from, " : Nr\n\r");
  899.         Integer HH1 =Integer.parseInt(_from.nextElement().toString());
  900.         Integer MM1 =Integer.parseInt(  _from.nextElement().toString() );
  901.         StringTokenizer _to = new StringTokenizer(to, " : Nr\n\r");
  902.         Integer HH2 =Integer.parseInt(_to.nextElement().toString());
  903.         Integer MM2 =Integer.parseInt(  _to.nextElement().toString() );
  904.         if (HH1 - HH2 >0 ){
  905.             return true;
  906.         }
  907.         if (( HH1 == HH2  )&&( MM1 - MM2  > 0  )){
  908.             return true;
  909.         }else {
  910.             return false;
  911.         }
  912.     }
  913.  
  914.     private Integer czastrwania(String dateStart, String dateStop){
  915.  
  916. // Custom date format
  917.         SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
  918.  
  919.         Date d1 = null;
  920.         Date d2 = null;
  921.         try {
  922.             d1 = format.parse(dateStart);
  923.             d2 = format.parse(dateStop);
  924.         } catch (ParseException e) {
  925.             e.printStackTrace();
  926.         }
  927.         long diff = d2.getTime() - d1.getTime();
  928.         long diffSeconds = diff / 1000 % 60;
  929.  
  930.         long diffMinutes = diff / (60 * 1000) % 60;
  931.         long diffHours = diff / (60 * 60 * 1000) % 24;
  932.         long diffDays = diff / (24 * 60 * 60 * 1000);
  933.  
  934.          return (int) (long) (diffMinutes + (diffHours * 60 ) + (diffDays * 24 * 60) );
  935.     }
  936.  
  937.     private boolean moreThanOneDay(String from, String to) {// HH:MM
  938.         StringTokenizer _from = new StringTokenizer(from, " : Nr\n\r");
  939.         String ymd =  _from.nextElement().toString();
  940.  
  941.         Integer HH1 =Integer.parseInt(_from.nextElement().toString());
  942.         Integer MM1 =Integer.parseInt(_from.nextElement().toString());
  943.         StringTokenizer _to = new StringTokenizer(to, " : Nr\n\r");
  944.         String ymd2 =  _to.nextElement().toString();
  945.  
  946.         Integer HH2 =Integer.parseInt(  _to.nextElement().toString() );
  947.         Integer MM2 =Integer.parseInt(  _to.nextElement().toString() );
  948.  
  949.         if ((HH1 == HH2 && MM1 > MM2)) {
  950.          //   Log.d(TAG, "(HH1 == HH2 && MM1 > MM2)"+ HH1 + " " + HH2 + " " + MM1 + " " + MM2);
  951.             return true;
  952.         } else if (HH1 > HH2) {
  953.            // Log.d(TAG, "(HH1 > HH2" + HH1 + " " + HH2);
  954.             return true;
  955.         }
  956.         return false;
  957.     }
  958.  
  959.     public void listViewOsoby() throws ParseException {
  960.  
  961.         List lables = new ArrayList();
  962.         countList = 0;
  963.         Log.d(TAG, "countList = " +countList );
  964.         Log.d(TAG, "ID_wybrani =  " + ID_wybrani );
  965.  
  966.                 ID_wybrani = "";
  967.         List<PracownikZlecenieInastalacyjne> pracownicy = db.getAllPracownikZlecenieInastalacyjne();
  968.         for(PracownikZlecenieInastalacyjne tmp : pracownicy){
  969.             if (tmp.getPzi_IdZlecenieInstalacyjne().equals(Raport.getZlecenieInstalacyjneID())){
  970.  
  971.                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  972.  
  973.                 Date _pracownikOd = sdf.parse(tmp.getPzi_DataOd());
  974.                 Date _pracownikDo = sdf.parse(tmp.getPzi_DataDo());
  975.                 Date _today = sdf.parse(raport.getRaportowanydzien());
  976.                 String auto = "";
  977.                 if((!_pracownikDo.before(_today))&&(!_today.before(_pracownikOd))){
  978. //
  979. //                    if(tmp.as_NrRejestracyjny!=null){
  980. //                        auto = " " + tmp.getAs_NrRejestracyjny();
  981. //                    } // niestety mam pózniej według tokenów
  982.  
  983.  
  984.                     lables.add( tmp.getPr_Imie() +"  "+ tmp.getPr_Nazwisko() + "  "  + tmp.getPr_NrEwidencyjny());
  985.  
  986.                     countList++;
  987.                     Log.d(TAG, "lables.add( " + tmp.getPr_Imie() +"\t"+ tmp.getPr_Nazwisko() + "\t"  + tmp.getPr_NrEwidencyjny() );
  988.                     Log.d(TAG, "countList  =" + countList);
  989.                 }
  990.  
  991.             }
  992.         }
  993.         //simple_list_item_multiple_choice
  994.         ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_checked, lables);
  995.         dataAdapter.setDropDownViewResource(android.R.layout.simple_list_item_checked);
  996.         listViewOsoby.setAdapter(dataAdapter);
  997.  
  998.         for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++) {
  999.             listViewOsoby.setItemChecked(z, true);
  1000.             Log.d(TAG, "z = " + z);
  1001.         }
  1002.  
  1003.         showGridView();
  1004.  
  1005.  
  1006.         Log.d(TAG, "countList = " + countList);
  1007.         Log.d(TAG, "ID_wybrani =  " + ID_wybrani);
  1008.  
  1009.     }
  1010.  
  1011.     private void setDate_setID(){
  1012.  
  1013.         Calendar mcurrentTime = Calendar.getInstance();
  1014.         String txt = getResources().getString(R.string.btnPodsumowaniesecond_frag);
  1015.         Integer day = mcurrentTime.get(Calendar.DATE);
  1016.         Integer month = mcurrentTime.get(Calendar.MONTH);
  1017.         Integer year = mcurrentTime.get(Calendar.YEAR);
  1018.  
  1019.         podsumowanie.setText(String.format(txt + " " + String.format("%02d", day) + "." + String.format("%02d", (month + 1)) + "." + year));
  1020.         raport.setRaportowanydzien(String.format(year
  1021.                 + "-" + (String.format("%02d", (month + 1)))
  1022.                 + "-" + (String.format("%02d", day))
  1023.                 + " 00:00:00"));
  1024.  
  1025.         raport.setRaportowanydzien_pomocnicze(String.format(year
  1026.                 + "-" + (String.format("%02d", (month + 1)))
  1027.                 + "-" + (String.format("%02d", day))));
  1028.  
  1029.         podsumowanie.setOnClickListener(new View.OnClickListener() {
  1030.             @Override
  1031.             public void onClick(View v) {
  1032.  
  1033.                 Raport.blokadapowrot = false;
  1034.                 Raport.blokadaprzerwa = false;
  1035.                 Raport.blokadapraca = false;
  1036.                 Raport.blokadadojazd = false;
  1037.                 Raport.blokadapowrot1 = false;
  1038.                 Raport.blokadaprzerwa1 = false;
  1039.                 Raport.blokadapraca1 = false;
  1040.                 Raport.blokadadojazd1 = false;
  1041.                 Raport.blokadapowrot2 = false;
  1042.                 Raport.blokadaprzerwa2 = false;
  1043.                 Raport.blokadapraca2 = false;
  1044.                 Raport.blokadadojazd2 = false;
  1045.  
  1046.                 Calendar time = Calendar.getInstance();
  1047.                 int day = time.get(Calendar.DAY_OF_MONTH);
  1048.                 int month = time.get(Calendar.MONTH);
  1049.                 int year = time.get(Calendar.YEAR);
  1050.  
  1051.                 DatePickerDialog datePickerDialog;
  1052.                 datePickerDialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
  1053.                     @Override
  1054.                     public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
  1055.                         String txt = getResources().getString(R.string.btnPodsumowaniesecond_frag);
  1056.  
  1057.                         raport.setRaportowanydzien(String.format(year
  1058.                                 + "-" + (String.format("%02d", (monthOfYear + 1)))
  1059.                                 + "-" + (String.format("%02d", dayOfMonth))
  1060.                                 + " 00:00:00"));
  1061.  
  1062.                         raport.setRaportowanydzien_pomocnicze(String.format(year
  1063.                                 + "-" + (String.format("%02d", (monthOfYear + 1)))
  1064.                                 + "-" + (String.format("%02d", dayOfMonth))));
  1065.  
  1066.                         podsumowanie.setText(String.format(txt + " " + String.format("%02d", dayOfMonth)
  1067.                                 + "." + String.format("%02d", (monthOfYear + 1)) + "." + year));
  1068.  
  1069.                         try {
  1070.                             listViewOsoby();
  1071.  
  1072.                         } catch (ParseException e) {
  1073.                             e.printStackTrace();
  1074.                         }
  1075.  
  1076.                     }
  1077.                 }, year, month, day);
  1078.                 datePickerDialog.show();
  1079.  
  1080.  
  1081.             }
  1082.  
  1083.             ;
  1084.         });
  1085.  
  1086.  
  1087.     }
  1088.  
  1089.     private void setTime(){
  1090.  
  1091.  
  1092.     dojazd_od.setOnClickListener(new View.OnClickListener() {
  1093.         @Override
  1094.         public void onClick(View v) {
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.             Boolean pokaz = true;
  1103.             Boolean pokazchocjedno = false; // jesli reszta jużwysłąna pokaze dla chociaż jednego niewysłąnego
  1104.  
  1105.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1106.  
  1107.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1108.             {
  1109.                 if (checked.get(z)) {
  1110.                     Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1111.  
  1112.                     String imie = "";
  1113.                     String nazwisko = "";
  1114.                     String nrEwidencyjny = "";
  1115.  
  1116.                     String ID = "";
  1117.  
  1118.                     String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1119.                     StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1120.                     while (str.hasMoreTokens()) {
  1121.                         imie = str.nextElement().toString();
  1122.                         nazwisko = str.nextElement().toString();
  1123.                         nrEwidencyjny = str.nextElement().toString();
  1124.                         Log.d(TAG, "imie = " + imie);
  1125.                         Log.d(TAG, "nazwisko = " + nazwisko);
  1126.                         Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1127.                         List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1128.                         for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1129.                             if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1130.                                 ID = curr.getPr_Id().toString();
  1131.  
  1132.                                 List<RaportRow> _wszystko = db.getAllRaport();
  1133.  
  1134.                                 int i = 0;
  1135.                                 for (RaportRow tmp : _wszystko ) {
  1136.  
  1137.                                     if(tmp.getRp_IdPracownik().equals(ID)){
  1138.                                         if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  1139.                                             if(tmp.getRp_TypOperacji().equals("dd")){
  1140.                                                 if(tmp.getRp_Wyslany().equals(1)){
  1141.                                                     pokaz = false;
  1142.                                                 }else{
  1143.                                                     pokazchocjedno = true;
  1144.                                                 }
  1145.  
  1146.                                             }
  1147.                                         }
  1148.                                     }
  1149.                                 }
  1150.                             }
  1151.                         }
  1152.                     }
  1153.                 }
  1154.  
  1155.             }
  1156.  
  1157.             if (pokaz||pokazchocjedno) {
  1158.  
  1159.  
  1160.  
  1161.                 Calendar mcurrentTime = Calendar.getInstance();
  1162.                 int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
  1163.                 int minute = mcurrentTime.get(Calendar.MINUTE);
  1164.                 TimePickerDialog mTimePicker;
  1165.  
  1166.                 mTimePicker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
  1167.                     @Override
  1168.                     public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
  1169.                         //       if (raport.dojazd_do.isEmpty()){Raport.blokadadojazd = true;}
  1170.  
  1171.                         dojazd_od_time = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
  1172.                         dojazd_od.setText(dojazd_od_time);
  1173.                         raport.setDojazd_od(raport.getRaportowanydzien_pomocnicze() + " " + dojazd_od_time + ":00");
  1174.                         Log.d(TAG, "raport.setDojazd_od = " + raport.getRaportowanydzien_pomocnicze() + " " + dojazd_od_time + ":00");
  1175.                         zapisz();
  1176.                         showGridView();
  1177.                     }
  1178.                 }, hour, minute, true);
  1179.  
  1180.                 mTimePicker.setCancelable(true);
  1181.                 mTimePicker.show();
  1182.             }
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.         }
  1190.     });
  1191.  
  1192.     dojazd_do.setOnClickListener(new View.OnClickListener() {
  1193.         @Override
  1194.         public void onClick(View v) {
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.             Boolean pokaz = true;
  1202.             Boolean pokazchocjedno = false; // jesli reszta jużwysłąna pokaze dla chociaż jednego niewysłąnego
  1203.  
  1204.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1205.  
  1206.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1207.             {
  1208.                 if (checked.get(z)) {
  1209.                     Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1210.  
  1211.                     String imie = "";
  1212.                     String nazwisko = "";
  1213.                     String nrEwidencyjny = "";
  1214.  
  1215.                     String ID = "";
  1216.  
  1217.                     String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1218.                     StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1219.                     while (str.hasMoreTokens()) {
  1220.                         imie = str.nextElement().toString();
  1221.                         nazwisko = str.nextElement().toString();
  1222.                         nrEwidencyjny = str.nextElement().toString();
  1223.                         Log.d(TAG, "imie = " + imie);
  1224.                         Log.d(TAG, "nazwisko = " + nazwisko);
  1225.                         Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1226.                         List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1227.                         for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1228.                             if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1229.                                 ID = curr.getPr_Id().toString();
  1230.  
  1231.                                 List<RaportRow> _wszystko = db.getAllRaport();
  1232.  
  1233.                                 int i = 0;
  1234.                                 for (RaportRow tmp : _wszystko ) {
  1235.  
  1236.                                     if(tmp.getRp_IdPracownik().equals(ID)){
  1237.                                         if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  1238.                                             if(tmp.getRp_TypOperacji().equals("dd")){
  1239.                                                 if(tmp.getRp_Wyslany().equals(1)){
  1240.                                                     pokaz = false;
  1241.                                                 }else{
  1242.                                                     pokazchocjedno = true;
  1243.                                                 }
  1244.  
  1245.                                             }
  1246.                                         }
  1247.                                     }
  1248.                                 }
  1249.                             }
  1250.                         }
  1251.                     }
  1252.                 }
  1253.  
  1254.             }
  1255.  
  1256.             if (pokaz||pokazchocjedno) {
  1257.  
  1258.  
  1259.  
  1260.  
  1261.                 Calendar mcurrentTime = Calendar.getInstance();
  1262.  
  1263.                 //   if (raport.dojazd_od.isEmpty()){Raport.blokadadojazd = true;}
  1264.  
  1265.                 int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
  1266.                 int minute = mcurrentTime.get(Calendar.MINUTE);
  1267.                 TimePickerDialog mTimePicker;
  1268.                 mTimePicker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
  1269.                     @Override
  1270.                     public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
  1271.  
  1272.                         dojazd_do_time = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
  1273.                         dojazd_do.setText(dojazd_do_time);
  1274.                         raport.setDojazd_do(String.format(raport.getRaportowanydzien_pomocnicze() + " " + "%02d", selectedHour) + ":" + String.format("%02d", selectedMinute) + ":00");
  1275.                         zapisz();
  1276.                         showGridView();
  1277.                     }
  1278.                 }, hour, minute, true);//Yes 24 hour time
  1279.  
  1280.                 mTimePicker.setTitle(getResources().getString(R.string.commuting_to_end));
  1281.                 mTimePicker.show();
  1282.  
  1283.  
  1284.             }
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.         }
  1291.     });
  1292.  
  1293.     powrot_od.setOnClickListener(new View.OnClickListener() {
  1294.         @Override
  1295.         public void onClick(View v) {
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.             Boolean pokaz = true;
  1303.             Boolean pokazchocjedno = false; // jesli reszta jużwysłąna pokaze dla chociaż jednego niewysłąnego
  1304.  
  1305.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1306.  
  1307.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1308.             {
  1309.                 if (checked.get(z)) {
  1310.                     Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1311.  
  1312.                     String imie = "";
  1313.                     String nazwisko = "";
  1314.                     String nrEwidencyjny = "";
  1315.  
  1316.                     String ID = "";
  1317.  
  1318.                     String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1319.                     StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1320.                     while (str.hasMoreTokens()) {
  1321.                         imie = str.nextElement().toString();
  1322.                         nazwisko = str.nextElement().toString();
  1323.                         nrEwidencyjny = str.nextElement().toString();
  1324.                         Log.d(TAG, "imie = " + imie);
  1325.                         Log.d(TAG, "nazwisko = " + nazwisko);
  1326.                         Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1327.                         List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1328.                         for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1329.                             if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1330.                                 ID = curr.getPr_Id().toString();
  1331.  
  1332.                                 List<RaportRow> _wszystko = db.getAllRaport();
  1333.  
  1334.                                 int i = 0;
  1335.                                 for (RaportRow tmp : _wszystko ) {
  1336.  
  1337.                                     if(tmp.getRp_IdPracownik().equals(ID)){
  1338.                                         if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  1339.                                             if(tmp.getRp_TypOperacji().equals("dz")){
  1340.                                                 if(tmp.getRp_Wyslany().equals(1)){
  1341.                                                     pokaz = false;
  1342.                                                 }else{
  1343.                                                     pokazchocjedno = true;
  1344.                                                 }
  1345.  
  1346.                                             }
  1347.                                         }
  1348.                                     }
  1349.                                 }
  1350.                             }
  1351.                         }
  1352.                     }
  1353.                 }
  1354.  
  1355.             }
  1356.  
  1357.             if (pokaz||pokazchocjedno) {
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.                 Calendar mcurrentTime = Calendar.getInstance();
  1365.                 int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
  1366.                 int minute = mcurrentTime.get(Calendar.MINUTE);
  1367.                 TimePickerDialog mTimePicker;
  1368.                 mTimePicker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
  1369.                     @Override
  1370.                     public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
  1371.                         //    if (raport.powrot_do.isEmpty()){Raport.blokadadojazd = true;}
  1372.  
  1373.                         powrot_od_time = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
  1374.                         powrot_od.setText(powrot_od_time);
  1375.                         raport.setPowrot_od(raport.getRaportowanydzien_pomocnicze() + " " + String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute) + ":00");
  1376.                         zapisz();
  1377.                         showGridView();
  1378.                     }
  1379.  
  1380.  
  1381.                 }, hour, minute, true);//Yes 24 hour time
  1382.  
  1383.                 mTimePicker.setTitle(getResources().getString(R.string.commuting_from_start));
  1384.                 mTimePicker.show();
  1385.  
  1386.  
  1387.             }
  1388.  
  1389.  
  1390.  
  1391.         }
  1392.     });
  1393.  
  1394.     powrot_do.setOnClickListener(new View.OnClickListener() {
  1395.         @Override
  1396.         public void onClick(View v) {
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.             Boolean pokaz = true;
  1403.             Boolean pokazchocjedno = false; // jesli reszta jużwysłąna pokaze dla chociaż jednego niewysłąnego
  1404.  
  1405.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1406.  
  1407.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1408.             {
  1409.                 if (checked.get(z)) {
  1410.                     Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1411.  
  1412.                     String imie = "";
  1413.                     String nazwisko = "";
  1414.                     String nrEwidencyjny = "";
  1415.  
  1416.                     String ID = "";
  1417.  
  1418.                     String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1419.                     StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1420.                     while (str.hasMoreTokens()) {
  1421.                         imie = str.nextElement().toString();
  1422.                         nazwisko = str.nextElement().toString();
  1423.                         nrEwidencyjny = str.nextElement().toString();
  1424.                         Log.d(TAG, "imie = " + imie);
  1425.                         Log.d(TAG, "nazwisko = " + nazwisko);
  1426.                         Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1427.                         List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1428.                         for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1429.                             if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1430.                                 ID = curr.getPr_Id().toString();
  1431.  
  1432.                                 List<RaportRow> _wszystko = db.getAllRaport();
  1433.  
  1434.                                 int i = 0;
  1435.                                 for (RaportRow tmp : _wszystko ) {
  1436.  
  1437.                                     if(tmp.getRp_IdPracownik().equals(ID)){
  1438.                                         if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  1439.                                             if(tmp.getRp_TypOperacji().equals("dz")){
  1440.                                                 if(tmp.getRp_Wyslany().equals(1)){
  1441.                                                     pokaz = false;
  1442.                                                 }else{
  1443.                                                     pokazchocjedno = true;
  1444.                                                 }
  1445.  
  1446.                                             }
  1447.                                         }
  1448.                                     }
  1449.                                 }
  1450.                             }
  1451.                         }
  1452.                     }
  1453.                 }
  1454.  
  1455.             }
  1456.  
  1457.             if (pokaz||pokazchocjedno) {
  1458.  
  1459.  
  1460.  
  1461.  
  1462.                 Calendar mcurrentTime = Calendar.getInstance();
  1463.                 int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
  1464.                 int minute = mcurrentTime.get(Calendar.MINUTE);
  1465.                 TimePickerDialog mTimePicker;
  1466.                 mTimePicker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
  1467.                     @Override
  1468.                     public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
  1469.                         //      if (raport.powrot_od.isEmpty()){Raport.blokadadojazd = true;}
  1470.  
  1471.  
  1472.                         powrot_do_time = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
  1473.                         powrot_do.setText(powrot_do_time);
  1474.                         raport.setPowrot_do(raport.getRaportowanydzien_pomocnicze() + " " + String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute) + ":00");
  1475.                         zapisz();
  1476.                         showGridView();
  1477.                     }
  1478.                 }, hour, minute, true);//Yes 24 hour time
  1479.  
  1480.                 mTimePicker.setTitle(getResources().getString(R.string.commuting_from_end));
  1481.                 mTimePicker.show();
  1482.  
  1483.  
  1484.             }
  1485.  
  1486.  
  1487.  
  1488.         }
  1489.     });
  1490.  
  1491.     praca_od.setOnClickListener(new View.OnClickListener() {
  1492.         @Override
  1493.         public void onClick(View v) {
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.             Boolean pokaz = true;
  1501.             Boolean pokazchocjedno = false; // jesli reszta jużwysłąna pokaze dla chociaż jednego niewysłąnego
  1502.  
  1503.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1504.  
  1505.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1506.             {
  1507.                 if (checked.get(z)) {
  1508.                     Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1509.  
  1510.                     String imie = "";
  1511.                     String nazwisko = "";
  1512.                     String nrEwidencyjny = "";
  1513.  
  1514.                     String ID = "";
  1515.  
  1516.                     String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1517.                     StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1518.                     while (str.hasMoreTokens()) {
  1519.                         imie = str.nextElement().toString();
  1520.                         nazwisko = str.nextElement().toString();
  1521.                         nrEwidencyjny = str.nextElement().toString();
  1522.                         Log.d(TAG, "imie = " + imie);
  1523.                         Log.d(TAG, "nazwisko = " + nazwisko);
  1524.                         Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1525.                         List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1526.                         for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1527.                             if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1528.                                 ID = curr.getPr_Id().toString();
  1529.  
  1530.                                 List<RaportRow> _wszystko = db.getAllRaport();
  1531.  
  1532.                                 int i = 0;
  1533.                                 for (RaportRow tmp : _wszystko ) {
  1534.  
  1535.                                     if(tmp.getRp_IdPracownik().equals(ID)){
  1536.                                         if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  1537.                                             if(tmp.getRp_TypOperacji().equals("pr")){
  1538.                                                 if(tmp.getRp_Wyslany().equals(1)){
  1539.                                                     pokaz = false;
  1540.                                                 }else{
  1541.                                                     pokazchocjedno = true;
  1542.                                                 }
  1543.  
  1544.                                             }
  1545.                                         }
  1546.                                     }
  1547.                                 }
  1548.                             }
  1549.                         }
  1550.                     }
  1551.                 }
  1552.  
  1553.             }
  1554.  
  1555.             if (pokaz||pokazchocjedno) {
  1556.  
  1557.  
  1558.  
  1559.  
  1560.                 Calendar mcurrentTime = Calendar.getInstance();
  1561.                 int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
  1562.                 int minute = mcurrentTime.get(Calendar.MINUTE);
  1563.                 TimePickerDialog mTimePicker;
  1564.                 mTimePicker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
  1565.                     @Override
  1566.                     public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
  1567.                         //    if (raport.praca_do.isEmpty()){Raport.blokadadojazd = true;}
  1568.  
  1569.                         praca_od_time = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
  1570.  
  1571.                         praca_od.setText(praca_od_time);
  1572.                         raport.setPraca_od(raport.getRaportowanydzien_pomocnicze() + " " + String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute) + ":00");
  1573.                         zapisz();
  1574.                         showGridView();
  1575.                     }
  1576.                 }, hour, minute, true);//Yes 24 hour time
  1577.  
  1578.                 mTimePicker.setTitle(getResources().getString(R.string.hours_start));
  1579.                 mTimePicker.show();
  1580.  
  1581.             }
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.         }
  1588.     });
  1589.  
  1590.     praca_do.setOnClickListener(new View.OnClickListener() {
  1591.         @Override
  1592.         public void onClick(View v) {
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.             Boolean pokaz = true;
  1600.             Boolean pokazchocjedno = false; // jesli reszta jużwysłąna pokaze dla chociaż jednego niewysłąnego
  1601.  
  1602.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1603.  
  1604.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1605.             {
  1606.                 if (checked.get(z)) {
  1607.                     Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1608.  
  1609.                     String imie = "";
  1610.                     String nazwisko = "";
  1611.                     String nrEwidencyjny = "";
  1612.  
  1613.                     String ID = "";
  1614.  
  1615.                     String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1616.                     StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1617.                     while (str.hasMoreTokens()) {
  1618.                         imie = str.nextElement().toString();
  1619.                         nazwisko = str.nextElement().toString();
  1620.                         nrEwidencyjny = str.nextElement().toString();
  1621.                         Log.d(TAG, "imie = " + imie);
  1622.                         Log.d(TAG, "nazwisko = " + nazwisko);
  1623.                         Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1624.                         List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1625.                         for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1626.                             if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1627.                                 ID = curr.getPr_Id().toString();
  1628.  
  1629.                                 List<RaportRow> _wszystko = db.getAllRaport();
  1630.  
  1631.                                 int i = 0;
  1632.                                 for (RaportRow tmp : _wszystko ) {
  1633.  
  1634.                                     if(tmp.getRp_IdPracownik().equals(ID)){
  1635.                                         if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  1636.                                             if(tmp.getRp_TypOperacji().equals("pr")){
  1637.                                                 if(tmp.getRp_Wyslany().equals(1)){
  1638.                                                     pokaz = false;
  1639.                                                 }else{
  1640.                                                     pokazchocjedno = true;
  1641.                                                 }
  1642.  
  1643.                                             }
  1644.                                         }
  1645.                                     }
  1646.                                 }
  1647.                             }
  1648.                         }
  1649.                     }
  1650.                 }
  1651.  
  1652.             }
  1653.  
  1654.             if (pokaz||pokazchocjedno) {
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.                 Calendar mcurrentTime = Calendar.getInstance();
  1661.                 int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
  1662.                 int minute = mcurrentTime.get(Calendar.MINUTE);
  1663.                 TimePickerDialog mTimePicker;
  1664.                 mTimePicker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
  1665.                     @Override
  1666.                     public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
  1667.                         //     if (raport.praca_od.isEmpty()){Raport.blokadadojazd = true;}
  1668.  
  1669.  
  1670.                         praca_do_time = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
  1671.                         praca_do.setText(praca_do_time);
  1672.                         raport.setPraca_do(raport.getRaportowanydzien_pomocnicze() + " " + String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute) + ":00");
  1673.                         zapisz();
  1674.                         showGridView();
  1675.                     }
  1676.                 }, hour, minute, true);//Yes 24 hour time
  1677.  
  1678.                 mTimePicker.setTitle(getResources().getString(R.string.hours_end));
  1679.                 mTimePicker.show();
  1680.  
  1681.             }
  1682.  
  1683.  
  1684.         }
  1685.     });
  1686.  
  1687.     lunch_od.setOnClickListener(new View.OnClickListener() {
  1688.         @Override
  1689.         public void onClick(View v) {
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.             Boolean pokaz = true;
  1697.             Boolean pokazchocjedno = false; // jesli reszta jużwysłąna pokaze dla chociaż jednego niewysłąnego
  1698.  
  1699.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1700.  
  1701.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1702.             {
  1703.                 if (checked.get(z)) {
  1704.                     Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1705.  
  1706.                     String imie = "";
  1707.                     String nazwisko = "";
  1708.                     String nrEwidencyjny = "";
  1709.  
  1710.                     String ID = "";
  1711.  
  1712.                     String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1713.                     StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1714.                     while (str.hasMoreTokens()) {
  1715.                         imie = str.nextElement().toString();
  1716.                         nazwisko = str.nextElement().toString();
  1717.                         nrEwidencyjny = str.nextElement().toString();
  1718.                         Log.d(TAG, "imie = " + imie);
  1719.                         Log.d(TAG, "nazwisko = " + nazwisko);
  1720.                         Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1721.                         List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1722.                         for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1723.                             if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1724.                                 ID = curr.getPr_Id().toString();
  1725.  
  1726.                                 List<RaportRow> _wszystko = db.getAllRaport();
  1727.  
  1728.                                 int i = 0;
  1729.                                 for (RaportRow tmp : _wszystko ) {
  1730.  
  1731.                                     if(tmp.getRp_IdPracownik().equals(ID)){
  1732.                                         if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  1733.                                             if(tmp.getRp_TypOperacji().equals("pz")){
  1734.                                                 if(tmp.getRp_Wyslany().equals(1)){
  1735.                                                     pokaz = false;
  1736.                                                 }else{
  1737.                                                     pokazchocjedno = true;
  1738.                                                 }
  1739.  
  1740.                                             }
  1741.                                         }
  1742.                                     }
  1743.                                 }
  1744.                             }
  1745.                         }
  1746.                     }
  1747.                 }
  1748.  
  1749.             }
  1750.  
  1751.             if (pokaz||pokazchocjedno) {
  1752.  
  1753.  
  1754.  
  1755.  
  1756.                 Calendar mcurrentTime = Calendar.getInstance();
  1757.                 int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
  1758.                 int minute = mcurrentTime.get(Calendar.MINUTE);
  1759.                 TimePickerDialog mTimePicker;
  1760.                 mTimePicker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
  1761.                     @Override
  1762.                     public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
  1763.  
  1764.  
  1765.                         //  Log.e(TAG,raport.lunch_do.toString());
  1766.  
  1767. //                    if (raport.lunch_do.equals("null")){Raport.blokadadojazd = true;}
  1768.  
  1769.  
  1770.                         lunch_od_time = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
  1771.                         lunch_od.setText(lunch_od_time);
  1772.                         raport.setLunch_od(raport.getRaportowanydzien_pomocnicze() + " " + String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute) + ":00");
  1773.                         zapisz();
  1774.                         showGridView();
  1775.                     }
  1776.                 }, hour, minute, true);//Yes 24 hour time
  1777.  
  1778.                 mTimePicker.setTitle(getResources().getString(R.string.break_start));
  1779.                 mTimePicker.show();
  1780.  
  1781.             }
  1782.  
  1783.  
  1784.  
  1785.  
  1786.         }
  1787.     });
  1788.  
  1789.     lunch_do.setOnClickListener(new View.OnClickListener() {
  1790.         @Override
  1791.         public void onClick(View v) {
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.             Boolean pokaz = true;
  1798.             Boolean pokazchocjedno = false; // jesli reszta jużwysłąna pokaze dla chociaż jednego niewysłąnego
  1799.  
  1800.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1801.  
  1802.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1803.             {
  1804.                 if (checked.get(z)) {
  1805.                     Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1806.  
  1807.                     String imie = "";
  1808.                     String nazwisko = "";
  1809.                     String nrEwidencyjny = "";
  1810.  
  1811.                     String ID = "";
  1812.  
  1813.                     String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1814.                     StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1815.                     while (str.hasMoreTokens()) {
  1816.                         imie = str.nextElement().toString();
  1817.                         nazwisko = str.nextElement().toString();
  1818.                         nrEwidencyjny = str.nextElement().toString();
  1819.                         Log.d(TAG, "imie = " + imie);
  1820.                         Log.d(TAG, "nazwisko = " + nazwisko);
  1821.                         Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1822.                         List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1823.                         for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1824.                             if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1825.                                 ID = curr.getPr_Id().toString();
  1826.  
  1827.                                 List<RaportRow> _wszystko = db.getAllRaport();
  1828.  
  1829.                                 int i = 0;
  1830.                                 for (RaportRow tmp : _wszystko ) {
  1831.  
  1832.                                     if(tmp.getRp_IdPracownik().equals(ID)){
  1833.                                         if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  1834.                                             if(tmp.getRp_TypOperacji().equals("pz")){
  1835.                                                 if(tmp.getRp_Wyslany().equals(1)){
  1836.                                                     pokaz = false;
  1837.                                                 }else{
  1838.                                                     pokazchocjedno = true;
  1839.                                                 }
  1840.  
  1841.                                             }
  1842.                                         }
  1843.                                     }
  1844.                                 }
  1845.                             }
  1846.                         }
  1847.                     }
  1848.                 }
  1849.  
  1850.             }
  1851.  
  1852.             if (pokaz||pokazchocjedno) {
  1853.  
  1854.  
  1855.  
  1856.  
  1857.                 Calendar mcurrentTime = Calendar.getInstance();
  1858.                 int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
  1859.                 int minute = mcurrentTime.get(Calendar.MINUTE);
  1860.                 TimePickerDialog mTimePicker;
  1861.                 mTimePicker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
  1862.                     @Override
  1863.                     public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
  1864.                         //  if (raport.lunch_od.equals("null")){Raport.blokadadojazd = true;}
  1865.  
  1866.                         lunch_do_time = String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute);
  1867.                         lunch_do.setText(lunch_do_time);
  1868.                         raport.setLunch_do(raport.getRaportowanydzien_pomocnicze() + " " + String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute) + ":00");
  1869.                         Log.d(TAG, "raport.getRaportowanydzien_pomocnicze() + \" \" + String.format(\"%02d\", selectedHour) + \":\" + String.format(\"%02d\", selectedMinute)+\":00\" " + raport.getRaportowanydzien_pomocnicze() + " " + String.format("%02d", selectedHour) + ":" + String.format("%02d", selectedMinute) + ":00");
  1870.  
  1871.                         zapisz();
  1872.  
  1873.                         showGridView();
  1874.  
  1875.                     }
  1876.                 }, hour, minute, true);//Yes 24 hour time
  1877.  
  1878.                 mTimePicker.setTitle(getResources().getString(R.string.break_end));
  1879.                 mTimePicker.show();
  1880.  
  1881.             }
  1882.  
  1883.  
  1884.         }
  1885.     });
  1886.  
  1887.  
  1888. }
  1889.  
  1890.     private void clear(){
  1891.  
  1892.         dojazd_od.setOnLongClickListener(new Button.OnLongClickListener() {
  1893.             public boolean onLongClick(View v) {
  1894.  
  1895.  
  1896.  
  1897.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1898.  
  1899.                     for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1900.                     {
  1901.                         if (checked.get(z)) {
  1902.                             Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1903.  
  1904.                             String imie = "";
  1905.                             String nazwisko = "";
  1906.                             String nrEwidencyjny = "";
  1907.  
  1908.                             String ID = "";
  1909.  
  1910.                             String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1911.                             StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1912.                             while (str.hasMoreTokens()) {
  1913.                                 imie = str.nextElement().toString();
  1914.                                 nazwisko = str.nextElement().toString();
  1915.                                 nrEwidencyjny = str.nextElement().toString();
  1916.                                 Log.d(TAG, "imie = " + imie);
  1917.                                 Log.d(TAG, "nazwisko = " + nazwisko);
  1918.                                 Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1919.                                 List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1920.                                 for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1921.                                     if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1922.                                         ID = curr.getPr_Id().toString();
  1923.  
  1924.                                         List<RaportRow> _wszystko = db.getAllRaport();
  1925.  
  1926.                                         int i = 0;
  1927.                                         for (RaportRow tmp : _wszystko ) {
  1928.  
  1929.                                             if(tmp.getRp_IdPracownik().equals(ID)){
  1930.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  1931.                                             if(tmp.getRp_TypOperacji().equals("dd")){
  1932.                                             if(tmp.getRp_Wyslany().equals(0)){
  1933.  
  1934.                                                 dojazd_od_time = String.format("");
  1935.                                                 dojazd_od.setText(dojazd_od_time);
  1936.                                                 dojazd_do.setText(dojazd_od_time);
  1937.                                                 raport.setDojazd_od(null);
  1938.                                                 raport.setDojazd_do(null);
  1939.                                                 raport.dojazd = false;
  1940.                                                 zapisz();
  1941.                                                 clearRow("dd");
  1942.                                                 showGridView();
  1943.  
  1944.  
  1945.  
  1946.  
  1947.                                             }
  1948.                                             }
  1949.                                             }
  1950.                                             }
  1951.                                         }
  1952.                                     }
  1953.                                 }
  1954.                             }
  1955.                         }
  1956.  
  1957.             }
  1958.                 return true;
  1959.             }
  1960.         });
  1961.  
  1962.         dojazd_do.setOnLongClickListener(new Button.OnLongClickListener() {
  1963.             public boolean onLongClick(View v) {
  1964.  
  1965.  
  1966.  
  1967.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  1968.  
  1969.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  1970.                 {
  1971.                     if (checked.get(z)) {
  1972.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  1973.  
  1974.                         String imie = "";
  1975.                         String nazwisko = "";
  1976.                         String nrEwidencyjny = "";
  1977.  
  1978.                         String ID = "";
  1979.  
  1980.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  1981.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  1982.                         while (str.hasMoreTokens()) {
  1983.                             imie = str.nextElement().toString();
  1984.                             nazwisko = str.nextElement().toString();
  1985.                             nrEwidencyjny = str.nextElement().toString();
  1986.                             Log.d(TAG, "imie = " + imie);
  1987.                             Log.d(TAG, "nazwisko = " + nazwisko);
  1988.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  1989.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  1990.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  1991.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  1992.                                     ID = curr.getPr_Id().toString();
  1993.  
  1994.                                     List<RaportRow> _wszystko = db.getAllRaport();
  1995.  
  1996.                                     int i = 0;
  1997.                                     for (RaportRow tmp : _wszystko ) {
  1998.  
  1999.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2000.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2001.                                                 if(tmp.getRp_TypOperacji().equals("dd")){
  2002.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2003.  
  2004.  
  2005.                                                         dojazd_od_time = String.format("");
  2006.                                                         dojazd_od.setText(dojazd_od_time);
  2007.                                                         dojazd_do.setText(dojazd_od_time);
  2008.                                                         raport.setDojazd_od(null);
  2009.                                                         raport.dojazd = false;
  2010.  
  2011.                                                         raport.setDojazd_do(null);
  2012.                                                         zapisz();
  2013.                                                         clearRow("dd");
  2014.  
  2015.                                                         showGridView();
  2016.  
  2017.  
  2018.                                                     }
  2019.                                                 }
  2020.                                             }
  2021.                                         }
  2022.                                     }
  2023.                                 }
  2024.                             }
  2025.                         }
  2026.                     }
  2027.  
  2028.                 }
  2029.  
  2030.  
  2031.                 return true;
  2032.             }
  2033.         });
  2034.  
  2035.         powrot_od.setOnLongClickListener(new Button.OnLongClickListener() {
  2036.             public boolean onLongClick(View v) {
  2037.  
  2038.             SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2039.  
  2040.             for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2041.             {
  2042.                 if (checked.get(z)) {
  2043.                     Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2044.  
  2045.                     String imie = "";
  2046.                     String nazwisko = "";
  2047.                     String nrEwidencyjny = "";
  2048.  
  2049.                     String ID = "";
  2050.  
  2051.                     String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2052.                     StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2053.                     while (str.hasMoreTokens()) {
  2054.                         imie = str.nextElement().toString();
  2055.                         nazwisko = str.nextElement().toString();
  2056.                         nrEwidencyjny = str.nextElement().toString();
  2057.                         Log.d(TAG, "imie = " + imie);
  2058.                         Log.d(TAG, "nazwisko = " + nazwisko);
  2059.                         Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2060.                         List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2061.                         for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2062.                             if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2063.                                 ID = curr.getPr_Id().toString();
  2064.  
  2065.                                 List<RaportRow> _wszystko = db.getAllRaport();
  2066.  
  2067.                                 int i = 0;
  2068.                                 for (RaportRow tmp : _wszystko ) {
  2069.  
  2070.                                     if(tmp.getRp_IdPracownik().equals(ID)){
  2071.                                         if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2072.                                             if(tmp.getRp_TypOperacji().equals("dz")){
  2073.                                                 if(tmp.getRp_Wyslany().equals(0)){
  2074.  
  2075.  
  2076.  
  2077.  
  2078.                                                         dojazd_od_time = String.format("");
  2079.                                                         powrot_od.setText(dojazd_od_time);
  2080.                                                         powrot_do.setText(dojazd_od_time);
  2081.                                                         raport.setPowrot_od(null);
  2082.                                                         raport.setPowrot_do(null);
  2083.                                                         raport.powrot = false;
  2084.                                                         zapisz();
  2085.                                                         clearRow("dz");
  2086.  
  2087.                                                         showGridView();
  2088.                                                 }
  2089.                                             }
  2090.                                         }
  2091.                                     }
  2092.                                 }
  2093.                             }
  2094.                         }
  2095.                     }
  2096.                 }
  2097.  
  2098.             }
  2099.  
  2100.  
  2101.  
  2102.  
  2103.                 return true;
  2104.             }
  2105.         });
  2106.  
  2107.         powrot_do.setOnLongClickListener(new Button.OnLongClickListener() {
  2108.             public boolean onLongClick(View v) {
  2109.  
  2110.  
  2111.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2112.  
  2113.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2114.                 {
  2115.                     if (checked.get(z)) {
  2116.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2117.  
  2118.                         String imie = "";
  2119.                         String nazwisko = "";
  2120.                         String nrEwidencyjny = "";
  2121.  
  2122.                         String ID = "";
  2123.  
  2124.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2125.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2126.                         while (str.hasMoreTokens()) {
  2127.                             imie = str.nextElement().toString();
  2128.                             nazwisko = str.nextElement().toString();
  2129.                             nrEwidencyjny = str.nextElement().toString();
  2130.                             Log.d(TAG, "imie = " + imie);
  2131.                             Log.d(TAG, "nazwisko = " + nazwisko);
  2132.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2133.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2134.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2135.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2136.                                     ID = curr.getPr_Id().toString();
  2137.  
  2138.                                     List<RaportRow> _wszystko = db.getAllRaport();
  2139.  
  2140.                                     int i = 0;
  2141.                                     for (RaportRow tmp : _wszystko ) {
  2142.  
  2143.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2144.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2145.                                                 if(tmp.getRp_TypOperacji().equals("dz")){
  2146.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2147.  
  2148.  
  2149.  
  2150.                                                         dojazd_od_time = String.format("");
  2151.                                                         powrot_od.setText(dojazd_od_time);
  2152.                                                         powrot_do.setText(dojazd_od_time);
  2153.                                                         raport.setPowrot_od(null);
  2154.                                                         raport.setPowrot_do(null);
  2155.                                                         raport.powrot = false;
  2156.                                                         zapisz();
  2157.                                                         clearRow("dz");
  2158.  
  2159.                                                         showGridView();
  2160.                                                     }
  2161.                                                 }
  2162.                                             }
  2163.                                         }
  2164.                                     }
  2165.                                 }
  2166.                             }
  2167.                         }
  2168.                     }
  2169.  
  2170.                 }
  2171.  
  2172.  
  2173.                 return true;
  2174.             }
  2175.         });
  2176.  
  2177.         praca_od.setOnLongClickListener(new Button.OnLongClickListener() {
  2178.             public boolean onLongClick(View v) {
  2179.  
  2180.  
  2181.  
  2182.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2183.  
  2184.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2185.                 {
  2186.                     if (checked.get(z)) {
  2187.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2188.  
  2189.                         String imie = "";
  2190.                         String nazwisko = "";
  2191.                         String nrEwidencyjny = "";
  2192.  
  2193.                         String ID = "";
  2194.  
  2195.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2196.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2197.                         while (str.hasMoreTokens()) {
  2198.                             imie = str.nextElement().toString();
  2199.                             nazwisko = str.nextElement().toString();
  2200.                             nrEwidencyjny = str.nextElement().toString();
  2201.                             Log.d(TAG, "imie = " + imie);
  2202.                             Log.d(TAG, "nazwisko = " + nazwisko);
  2203.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2204.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2205.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2206.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2207.                                     ID = curr.getPr_Id().toString();
  2208.  
  2209.                                     List<RaportRow> _wszystko = db.getAllRaport();
  2210.  
  2211.                                     int i = 0;
  2212.                                     for (RaportRow tmp : _wszystko ) {
  2213.  
  2214.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2215.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2216.                                                 if(tmp.getRp_TypOperacji().equals("pr")){
  2217.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.                                                         dojazd_od_time = String.format("");
  2224.                                                         praca_od.setText(dojazd_od_time);
  2225.                                                         praca_do.setText(dojazd_od_time);
  2226.                                                         raport.setPraca_od(null);
  2227.                                                         raport.setPraca_do(null);
  2228.                                                         raport.praca = false;
  2229.                                                         zapisz();
  2230.                                                         clearRow("pr");
  2231.  
  2232.                                                         showGridView();
  2233.                                                     }
  2234.                                                 }
  2235.                                             }
  2236.                                         }
  2237.                                     }
  2238.                                 }
  2239.                             }
  2240.                         }
  2241.                     }
  2242.  
  2243.                 }
  2244.  
  2245.                 return true;
  2246.             }
  2247.         });
  2248.  
  2249.         praca_do.setOnLongClickListener(new Button.OnLongClickListener() {
  2250.             public boolean onLongClick(View v) {
  2251.  
  2252.  
  2253.  
  2254.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2255.  
  2256.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2257.                 {
  2258.                     if (checked.get(z)) {
  2259.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2260.  
  2261.                         String imie = "";
  2262.                         String nazwisko = "";
  2263.                         String nrEwidencyjny = "";
  2264.  
  2265.                         String ID = "";
  2266.  
  2267.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2268.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2269.                         while (str.hasMoreTokens()) {
  2270.                             imie = str.nextElement().toString();
  2271.                             nazwisko = str.nextElement().toString();
  2272.                             nrEwidencyjny = str.nextElement().toString();
  2273.                             Log.d(TAG, "imie = " + imie);
  2274.                             Log.d(TAG, "nazwisko = " + nazwisko);
  2275.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2276.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2277.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2278.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2279.                                     ID = curr.getPr_Id().toString();
  2280.  
  2281.                                     List<RaportRow> _wszystko = db.getAllRaport();
  2282.  
  2283.                                     int i = 0;
  2284.                                     for (RaportRow tmp : _wszystko ) {
  2285.  
  2286.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2287.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2288.                                                 if(tmp.getRp_TypOperacji().equals("pr")){
  2289.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.                                                         dojazd_od_time = String.format("");
  2296.                                                         praca_od.setText(dojazd_od_time);
  2297.                                                         praca_do.setText(dojazd_od_time);
  2298.                                                         raport.setPraca_od(null);
  2299.                                                         raport.setPraca_do(null);
  2300.                                                         raport.praca = false;
  2301.                                                         zapisz();
  2302.                                                         clearRow("pr");
  2303.  
  2304.                                                         showGridView();
  2305.                                                     }
  2306.                                                 }
  2307.                                             }
  2308.                                         }
  2309.                                     }
  2310.                                 }
  2311.                             }
  2312.                         }
  2313.                     }
  2314.  
  2315.                 }
  2316.  
  2317.                 return true;
  2318.             }
  2319.         });
  2320.  
  2321.         lunch_od.setOnLongClickListener(new Button.OnLongClickListener() {
  2322.             public boolean onLongClick(View v) {
  2323.  
  2324.  
  2325.  
  2326.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2327.  
  2328.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2329.                 {
  2330.                     if (checked.get(z)) {
  2331.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2332.  
  2333.                         String imie = "";
  2334.                         String nazwisko = "";
  2335.                         String nrEwidencyjny = "";
  2336.  
  2337.                         String ID = "";
  2338.  
  2339.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2340.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2341.                         while (str.hasMoreTokens()) {
  2342.                             imie = str.nextElement().toString();
  2343.                             nazwisko = str.nextElement().toString();
  2344.                             nrEwidencyjny = str.nextElement().toString();
  2345.                             Log.d(TAG, "imie = " + imie);
  2346.                             Log.d(TAG, "nazwisko = " + nazwisko);
  2347.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2348.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2349.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2350.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2351.                                     ID = curr.getPr_Id().toString();
  2352.  
  2353.                                     List<RaportRow> _wszystko = db.getAllRaport();
  2354.  
  2355.                                     int i = 0;
  2356.                                     for (RaportRow tmp : _wszystko ) {
  2357.  
  2358.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2359.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2360.                                                 if(tmp.getRp_TypOperacji().equals("pz")){
  2361.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2362.  
  2363.  
  2364.  
  2365.                                                         dojazd_od_time = String.format("");
  2366.                                                         lunch_od.setText(dojazd_od_time);
  2367.                                                         lunch_do.setText(dojazd_od_time);
  2368.                                                         raport.setLunch_od(null);
  2369.                                                         raport.setLunch_do(null);
  2370.                                                         raport.przerwa = false;
  2371.                                                         zapisz();
  2372.                                                         clearRow("pz");
  2373.  
  2374.                                                         showGridView();
  2375.                                                     }
  2376.                                                 }
  2377.                                             }
  2378.                                         }
  2379.                                     }
  2380.                                 }
  2381.                             }
  2382.                         }
  2383.                     }
  2384.  
  2385.                 }
  2386.  
  2387.                 return true;
  2388.             }
  2389.         });
  2390.  
  2391.         lunch_do.setOnLongClickListener(new Button.OnLongClickListener() {
  2392.             public boolean onLongClick(View v) {
  2393.  
  2394.  
  2395.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2396.  
  2397.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2398.                 {
  2399.                     if (checked.get(z)) {
  2400.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2401.  
  2402.                         String imie = "";
  2403.                         String nazwisko = "";
  2404.                         String nrEwidencyjny = "";
  2405.  
  2406.                         String ID = "";
  2407.  
  2408.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2409.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2410.                         while (str.hasMoreTokens()) {
  2411.                             imie = str.nextElement().toString();
  2412.                             nazwisko = str.nextElement().toString();
  2413.                             nrEwidencyjny = str.nextElement().toString();
  2414.                             Log.d(TAG, "imie = " + imie);
  2415.                             Log.d(TAG, "nazwisko = " + nazwisko);
  2416.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2417.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2418.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2419.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2420.                                     ID = curr.getPr_Id().toString();
  2421.  
  2422.                                     List<RaportRow> _wszystko = db.getAllRaport();
  2423.  
  2424.                                     int i = 0;
  2425.                                     for (RaportRow tmp : _wszystko ) {
  2426.  
  2427.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2428.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2429.                                                 if(tmp.getRp_TypOperacji().equals("pz")){
  2430.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2431.  
  2432.  
  2433.  
  2434.                                                         dojazd_od_time = String.format("");
  2435.                                                         lunch_od.setText(dojazd_od_time);
  2436.                                                         lunch_do.setText(dojazd_od_time);
  2437.                                                         raport.setLunch_od(null);
  2438.                                                         raport.setLunch_do(null);
  2439.                                                         raport.przerwa = false;
  2440.  
  2441.                                                         zapisz();
  2442.                                                         clearRow("pz");
  2443.  
  2444.                                                         showGridView();
  2445.                                                     }
  2446.                                                 }
  2447.                                             }
  2448.                                         }
  2449.                                     }
  2450.                                 }
  2451.                             }
  2452.                         }
  2453.                     }
  2454.  
  2455.                 }
  2456.  
  2457.  
  2458.                 return true;
  2459.  
  2460.             }
  2461.         });
  2462.  
  2463.     }
  2464.  
  2465.     private void clearRow(String typ){
  2466.  
  2467.         SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2468.         for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++) {
  2469.             if (checked.get(z)) {
  2470.                 Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2471.  
  2472.                 String imie = "";
  2473.                 String nazwisko = "";
  2474.                 String nrEwidencyjny = "";
  2475.  
  2476.                 String ID = "";
  2477.  
  2478.                 String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2479.                 StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2480.  
  2481.                 while (str.hasMoreTokens()) {
  2482.                     imie = str.nextElement().toString();
  2483.                     nazwisko = str.nextElement().toString();
  2484.                     nrEwidencyjny = str.nextElement().toString();
  2485.  
  2486.                     List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2487.                     for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2488.                         if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2489.  
  2490.                             ID = curr.getPr_Id().toString();
  2491.  
  2492.                             RaportRow raportRow = new RaportRow();
  2493.  
  2494.                             raportRow.setRp_TypOperacji(typ);
  2495.                             raportRow.setRp_DataOd(raport.getRaportowanydzien());
  2496.                             raportRow.setRp_IdPracownik(Integer.parseInt(ID));
  2497.                             raportRow.setRp_IdZlecenieInstalacyjne(raport.getZlecenieInstalacyjneID());
  2498.  
  2499.                             db.deleteSimilarRaportRow(raportRow);
  2500.                             Log.d(TAG, "usuwam "+ raportRow.help() );
  2501.                         }
  2502.                     }
  2503.                 }
  2504.             }
  2505.         }
  2506.     }
  2507.  
  2508.     private void clearline(){
  2509.  
  2510.  
  2511.         dojazd.setOnLongClickListener(new Button.OnLongClickListener() {
  2512.             public boolean onLongClick(View v) {
  2513.  
  2514.  
  2515.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2516.  
  2517.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2518.                 {
  2519.                     if (checked.get(z)) {
  2520.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2521.  
  2522.                         String imie = "";
  2523.                         String nazwisko = "";
  2524.                         String nrEwidencyjny = "";
  2525.  
  2526.                         String ID = "";
  2527.  
  2528.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2529.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2530.                         while (str.hasMoreTokens()) {
  2531.                             imie = str.nextElement().toString();
  2532.                             nazwisko = str.nextElement().toString();
  2533.                             nrEwidencyjny = str.nextElement().toString();
  2534.                             Log.d(TAG, "imie = " + imie);
  2535.                             Log.d(TAG, "nazwisko = " + nazwisko);
  2536.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2537.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2538.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2539.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2540.                                     ID = curr.getPr_Id().toString();
  2541.  
  2542.                                     List<RaportRow> _wszystko = db.getAllRaport();
  2543.  
  2544.                                     int i = 0;
  2545.                                     for (RaportRow tmp : _wszystko ) {
  2546.  
  2547.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2548.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2549.                                                 if(tmp.getRp_TypOperacji().equals("dd")){
  2550.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2551.  
  2552.                                                         dojazd_od.setText("");
  2553.                                                         dojazd_do.setText("");
  2554.                                                         raport.setDojazd_od(null);
  2555.                                                         raport.setDojazd_do(null);
  2556.                                                         raport.dojazd = false;
  2557.  
  2558.                                                         zapisz();
  2559.                                                         clearRow("dd");
  2560.  
  2561.                                                         showGridView();
  2562.                                                     }
  2563.                                                 }
  2564.                                             }
  2565.                                         }
  2566.                                     }
  2567.                                 }
  2568.                             }
  2569.                         }
  2570.                     }
  2571.  
  2572.                 }
  2573.  
  2574.  
  2575.                 return true;
  2576.             }
  2577.         });
  2578.         praca.setOnLongClickListener(new Button.OnLongClickListener() {
  2579.             public boolean onLongClick(View v) {
  2580.  
  2581.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2582.  
  2583.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2584.                 {
  2585.                     if (checked.get(z)) {
  2586.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2587.  
  2588.                         String imie = "";
  2589.                         String nazwisko = "";
  2590.                         String nrEwidencyjny = "";
  2591.  
  2592.                         String ID = "";
  2593.  
  2594.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2595.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2596.                         while (str.hasMoreTokens()) {
  2597.                             imie = str.nextElement().toString();
  2598.                             nazwisko = str.nextElement().toString();
  2599.                             nrEwidencyjny = str.nextElement().toString();
  2600.                             Log.d(TAG, "imie = " + imie);
  2601.                             Log.d(TAG, "nazwisko = " + nazwisko);
  2602.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2603.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2604.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2605.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2606.                                     ID = curr.getPr_Id().toString();
  2607.  
  2608.                                     List<RaportRow> _wszystko = db.getAllRaport();
  2609.  
  2610.                                     int i = 0;
  2611.                                     for (RaportRow tmp : _wszystko ) {
  2612.  
  2613.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2614.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2615.                                                 if(tmp.getRp_TypOperacji().equals("pr")){
  2616.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2617.  
  2618.                                                         praca_od.setText("");
  2619.                                                         praca_do.setText("");
  2620.                                                         raport.setPraca_od(null);
  2621.                                                         raport.praca = false;
  2622.  
  2623.                                                         raport.setPraca_do(null);
  2624.                                                         zapisz();
  2625.                                                         clearRow("pr");
  2626.  
  2627.                                                         showGridView();
  2628.                                                     }
  2629.                                                 }
  2630.                                             }
  2631.                                         }
  2632.                                     }
  2633.                                 }
  2634.                             }
  2635.                         }
  2636.                     }
  2637.  
  2638.                 }
  2639.  
  2640.  
  2641.                 return true;
  2642.             }
  2643.         });
  2644.         powrot.setOnLongClickListener(new Button.OnLongClickListener() {
  2645.             public boolean onLongClick(View v) {
  2646.  
  2647.  
  2648.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2649.  
  2650.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2651.                 {
  2652.                     if (checked.get(z)) {
  2653.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2654.  
  2655.                         String imie = "";
  2656.                         String nazwisko = "";
  2657.                         String nrEwidencyjny = "";
  2658.  
  2659.                         String ID = "";
  2660.  
  2661.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2662.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2663.                         while (str.hasMoreTokens()) {
  2664.                             imie = str.nextElement().toString();
  2665.                             nazwisko = str.nextElement().toString();
  2666.                             nrEwidencyjny = str.nextElement().toString();
  2667.                             Log.d(TAG, "imie = " + imie);
  2668.                             Log.d(TAG, "nazwisko = " + nazwisko);
  2669.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2670.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2671.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2672.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2673.                                     ID = curr.getPr_Id().toString();
  2674.  
  2675.                                     List<RaportRow> _wszystko = db.getAllRaport();
  2676.  
  2677.                                     int i = 0;
  2678.                                     for (RaportRow tmp : _wszystko ) {
  2679.  
  2680.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2681.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2682.                                                 if(tmp.getRp_TypOperacji().equals("dz")){
  2683.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2684.  
  2685.  
  2686.                                                         powrot_od.setText("");
  2687.                                                         powrot_do.setText("");
  2688.                                                         raport.setPowrot_od(null);
  2689.                                                         raport.setPowrot_do(null);
  2690.                                                         raport.powrot = false;
  2691.                                                         zapisz();
  2692.                                                         clearRow("dz");
  2693.  
  2694.                                                         showGridView();
  2695.                                                     }
  2696.                                                 }
  2697.                                             }
  2698.                                         }
  2699.                                     }
  2700.                                 }
  2701.                             }
  2702.                         }
  2703.                     }
  2704.  
  2705.                 }
  2706.  
  2707.                 return true;
  2708.             }
  2709.         });
  2710.         przerwa.setOnLongClickListener(new Button.OnLongClickListener() {
  2711.             public boolean onLongClick(View v) {
  2712.  
  2713.  
  2714.                 SparseBooleanArray checked = listViewOsoby.getCheckedItemPositions();
  2715.  
  2716.                 for (int z = 0; z < listViewOsoby.getAdapter().getCount(); z++)
  2717.                 {
  2718.                     if (checked.get(z)) {
  2719.                         Log.d(TAG, listViewOsoby.getAdapter().getItem(z).toString());
  2720.  
  2721.                         String imie = "";
  2722.                         String nazwisko = "";
  2723.                         String nrEwidencyjny = "";
  2724.  
  2725.                         String ID = "";
  2726.  
  2727.                         String _str = listViewOsoby.getAdapter().getItem(z).toString();
  2728.                         StringTokenizer str = new StringTokenizer(_str, " \t\n\r");
  2729.                         while (str.hasMoreTokens()) {
  2730.                             imie = str.nextElement().toString();
  2731.                             nazwisko = str.nextElement().toString();
  2732.                             nrEwidencyjny = str.nextElement().toString();
  2733.                             Log.d(TAG, "imie = " + imie);
  2734.                             Log.d(TAG, "nazwisko = " + nazwisko);
  2735.                             Log.d(TAG, "nrEwidencyjny = " + nrEwidencyjny);
  2736.                             List<PracownikZlecenieInastalacyjne> wszystko = db.getAllPracownikZlecenieInastalacyjne();
  2737.                             for (PracownikZlecenieInastalacyjne curr : wszystko) {
  2738.                                 if (curr.getPr_NrEwidencyjny().equals(nrEwidencyjny)) {
  2739.                                     ID = curr.getPr_Id().toString();
  2740.  
  2741.                                     List<RaportRow> _wszystko = db.getAllRaport();
  2742.  
  2743.                                     int i = 0;
  2744.                                     for (RaportRow tmp : _wszystko ) {
  2745.  
  2746.                                         if(tmp.getRp_IdPracownik().equals(ID)){
  2747.                                             if(tmp.getRp_DataOd().substring(0, 10).equals(raport.getRaportowanydzien().substring(0, 10))){
  2748.                                                 if(tmp.getRp_TypOperacji().equals("pz")){
  2749.                                                     if(tmp.getRp_Wyslany().equals(0)){
  2750.  
  2751.  
  2752.                                                         lunch_od.setText("");
  2753.                                                         lunch_do.setText("");
  2754.                                                         raport.setLunch_od(null);
  2755.                                                         raport.setLunch_do(null);
  2756.                                                         raport.przerwa = false;
  2757.                                                         clearRow("pz");
  2758.                                                         zapisz();
  2759.  
  2760.                                                         showGridView();
  2761.                                                     }
  2762.                                                 }
  2763.                                             }
  2764.                                         }
  2765.                                     }
  2766.                                 }
  2767.                             }
  2768.                         }
  2769.                     }
  2770.  
  2771.                 }
  2772.  
  2773.  
  2774.                 return true;
  2775.             }
  2776.         });
  2777.         koszt.setOnLongClickListener(new Button.OnLongClickListener() {
  2778.             public boolean onLongClick(View v) {
  2779.                 raport.koszty = false;
  2780.  
  2781.                 return true;
  2782.             }
  2783.         });
  2784.  
  2785.     }
  2786.  
  2787.     public static SecondFragment newInstance(String text) {
  2788.  
  2789.         SecondFragment f = new SecondFragment();
  2790.         Bundle b = new Bundle();
  2791.         f.setArguments(b);
  2792.         return f;
  2793.     }
  2794.  
  2795. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement