Thursday 21 June 2012

Joomla Payroll System - Changing the 'add timesheets' page to submit to it's own page.

The following was an update for Joomla Payroll System to make the 'add timesheet' form go back to its own page.

in components/com_projectfork/views/add_timesheet/view.html.php  

 this is the code that was editing out.

###############################



/*           
            $user_id = JRequest::getVar('staff_id', '', 'POST');
            $project_id = JRequest::getVar('venue_id', '', 'POST');
           $start_time = JRequest::getVar('start_time', '', 'POST');
            $end_time = JRequest::getVar('end_time', '', 'POST');
            $hourly_rate = JRequest::getVar('hourly_rate', '', 'POST');
            $invoice_rate = JRequest::getVar('invoice_rate', '', 'POST');
            $shift_time = JRequest::getVar('timelog', '', 'POST');
            $cdate = JRequest::getVar('cdate', '', 'POST');
            $shift_pd = JRequest::getVar('post_date_entry', '0', 'POST');
           
             $start_hours = JRequest::getVar('start_hours', '', 'POST');
             $start_minutes = JRequest::getVar('start_minutes', '', 'POST');
             $end_hours = JRequest::getVar('end_hours', '', 'POST');
             $end_minutes = JRequest::getVar('end_minutes', '', 'POST');
          
           $task_id = JRequest::getVar('task_id', '', 'POST');


            $this->assign('st_sel', $user_id);
            $this->assign('tsk_sel', $task_id);
            $this->assign('vn_sel', $project_id);
            $this->assign('start_time', $start_time);
            $this->assign('start_time', $start_time);
            $this->assign('hourly_rate', $hourly_rate);
            $this->assign('invoice_rate', $invoice_rate);
            $this->assign('timelog', $shift_time);
            $this->assign('cdate', $cdate);

            $this->assign('post_date_entry', $shift_pd);
            $this->assign('start_hours',$start_hours);
            $this->assign('start_minutes',$start_minutes);
            $this->assign('start_hours',$end_hours);
            $this->assign('start_minutes',$end_minutes);*/
          
########################

and replaced with

      $user_id = JRequest::getVar('staff_id', '', 'POST');
            $project_id = JRequest::getVar('venue_id', '', 'POST');
            $hourly_rate = JRequest::getVar('hourly_rate', '', 'POST');
            $invoice_rate = JRequest::getVar('invoice_rate', '', 'POST');
            $shift_time = JRequest::getVar('timelog', '', 'POST');
          $task_id = JRequest::getVar('task_id', '', 'POST');
       

            //$start_time = JRequest::getVar('start_time', '', 'POST').":00";
            //$end_time = JRequest::getVar('start_time', '', 'POST').":00";
            $shift_time_arr = explode(':',$shift_time);
            @$timelog = intval($shift_time_arr[0])*60 + intval($shift_time_arr[1]);
         //   $cdate = strtotime(JRequest::getVar('cdate', '', 'POST'));
             $cdate1 =  JRequest::getVar('cdate', '', 'POST') ;
            $cdate2 = str_replace("/","-",$cdate1);
             $cdate=strtotime($cdate2);
            $shift_pd = JRequest::getVar('post_date_entry', '0', 'POST');
            $shift_pd = ($shift_pd=='on')?1:0;
           
           
           
             $start_hours = JRequest::getVar('start_hours', '', 'POST');
             $start_minutes = JRequest::getVar('start_minutes', '', 'POST');
              $end_hours = JRequest::getVar('end_hours', '', 'POST');
             $end_minutes = JRequest::getVar('end_minutes', '', 'POST');
          
              $start_time=$start_hours.":".$start_minutes;
              $end_time=$end_hours.":".$end_minutes;
             if($user_id && $project_id && $hourly_rate && $invoice_rate && $cdate){
               
                $db = & JFactory::getDBO();
                $query = "INSERT INTO #__pf_time_tracking (`task_id`, `project_id`, `user_id`, `content`, `cdate`, `timelog`, `hourly_rate`, `invoice_rate`, `post_date_entry`,`start_time`,`end_time`)"
                              ." VALUES ($task_id, $project_id, $user_id, '', $cdate, $timelog, $hourly_rate, $invoice_rate, $shift_pd,'".$start_time."','".$end_time."')";
                $db->setQuery($query);
                $db->query();
                $id = $db->insertid();

                if(!$id) {
                    $this->AddError($db->getErrorMsg());
                    return false;
                }
                else
                {
                     echo   "Thank you for entering a Timesheet Feel free to add more. ";
                 $this->assign('st_sel', 0);
            $this->assign('tsk_sel', 0);
            $this->assign('vn_sel', 0);
            $this->assign('hourly_rate', '0.00');
            $this->assign('invoice_rate', '0.00');
           
                   
            $this->assign('cdate',date("d/m/Y"));
           
           
           // $this->assign('cdate', 'DD-MM-YYYY');
            //$this->assign('timelog', 'HH:MM');
            $this->assign('start_time', 'HH:MM');
            $this->assign('end_time', 'HH:MM');
            $this->assign('start_hours', '00');
            $this->assign('start_minutes', '00');
            $this->assign('end_hours', '00');
            $this->assign('end_minutes', '00');
             
                }
                   
                    // $mainframe->redirect('index.php?option=com_projectfork&view=timesheets');
       
            // $mainframe = &JFactory::getApplication();
             //  $mainframe->redirect('index.php?option=com_projectfork&view=add_timesheet&Itemid=555');
           
            }
           
           
           
            






No comments: