function show($params)
 {
     if (!$params['id']) {
         bail('Required $params["id"] not present.');
     }
     $d = $this->data;
     $d->hour = new Hour($params['id']);
     $d->support_contract = new SupportContract($d->hour->get('support_contract_id'));
     $d->support_hours = Hour::getMany(array('support_contract_id' => $d->support_contract->id, 'sort' => 'date DESC'));
     $d->new_hour = new Hour();
     $d->new_hour->set(array('support_contract_id' => $d->support_contract->id, 'staff_id' => Session::getUserId(), 'date' => date('Y-m-d')));
 }
 function overview($params)
 {
     $ret_array = array();
     if (isset($params['range']) && $params['range'] != '') {
         $range = $params['range'];
     } else {
         $range = 1;
     }
     if (isset($params['navigation']) && $params['navigation'] != '') {
         $navigation = $params['navigation'];
     } else {
         $navigation = -1;
     }
     $start_date = date('Y-m-d', strtotime($range * $navigation . ' month'));
     if (isset($params['end_date']) && $params['end_date'] != '') {
         $end_date = $params['end_date'];
     } else {
         $end_date = date('Y-m-d', strtotime($start_date . ' +' . $range . ' months'));
     }
     switch ($range) {
         case 1:
             $send_end_date = $end_date;
             break;
         case 3:
         case 6:
             $start_date = date('Y-m-d', strtotime('-1 sunday', strtotime($start_date)));
             $end_date = date('Y-m-d', strtotime('+0 saturday', strtotime($end_date)));
             $send_end_date = date('Y-m-d', strtotime('-1 sunday', strtotime($end_date)));
             break;
         case 12:
             $start_date = date('Y-m-01', strtotime($start_date));
             $end_date = date('Y-m-t', strtotime($end_date));
             $send_end_date = date('Y-m-01', strtotime($end_date));
             break;
     }
     $hours = Hour::getMany(array('staff_id' => $params['id'], 'hour_search' => array('start_date' => $start_date, 'end_date' => $end_date)));
     $hours_array = array();
     foreach ($hours as $hour) {
         switch ($range) {
             case 3:
             case 6:
                 $hour->itemdata['date'] = date('Y-m-d', strtotime('-1 sunday', strtotime($hour->itemdata['date'])));
                 break;
             case 12:
                 $hour->itemdata['date'] = date('Y-m-01', strtotime($hour->itemdata['date']));
                 break;
         }
         array_push($hours_array, array('date' => $hour->itemdata['date'], 'hours' => $hour->itemdata['hours'] - $hour->itemdata['discount'], 'discount' => $hour->itemdata['discount']));
     }
     $this->data->hours = $hours_array;
     $this->data->start_date = $start_date;
     $this->data->end_date = $send_end_date;
 }
Exemple #3
0
 function getHours($search_criteria = array())
 {
     $criteria = array_merge(array('estimate_id' => $this->id), $search_criteria, array('sort' => 'date DESC'));
     $this->hours = Hour::getMany($criteria);
     return $this->hours;
 }
 function getHours($criteria = array())
 {
     $criteria = array_merge(array('support_contract_id' => $this->id), $criteria);
     $this->hours = Hour::getMany($criteria);
     return $this->hours;
 }
 function search($params)
 {
     $a_year_ago = date('Y-m-d', time() - 60 * 60 * 24 * 365);
     $default_query = array('hour_search' => array('start_date' => $a_year_ago), 'sort' => 'date DESC');
     $c = array_merge($default_query, $this->search_params('hour_search'));
     if (isset($params['sort'])) {
         $c['sort'] = $params['sort'];
     }
     if (!empty($params['company'])) {
         $c['company'] = $params['company'];
     }
     if (!empty($params['staff_id'])) {
         $c['staff_id'] = $params['staff_id'];
     }
     $this->data = Hour::getMany($c);
     $this->options = $params;
 }