Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PHP by Triada ( 15 years ago )
<?php
class Action_Other_Monthreport extends Action_Other
{
    protected function _index()
    {
        if (isset($this->request->post['action'])) {
            switch ($this->request->post['action']) {
                case 'make_monthreport':
                    return $this->makeMonthreport();
                break;
            }
        }

        return false;
    }

    protected function makeMonthreport()
    {
        $staffId = $this->currentUserId;
        $date = strtotime($this->request->post['date']);

        $reportList = $this->request->post['report'];
        
        $reportId = isset($this->request->post['monthreport_id'])?(int)$this->request->post['monthreport_id']:false;
        
        $actionResult = new MYLS_ActionResult();
        $modelMonthreport = HRLib_Myls_Model_MonthReport::create();

        if ( $staffId && $date && !empty($reportList) ) {
            $monthreportData =
                array(
                    'id' => ($reportId>0)?$reportId:false,
                    'report_month' => date('Y-m-d', $date),
                    'staff_id' => $staffId,
                    'report' => array()
                );

            foreach($reportList as $type => $data) {
                $monthreportData['report'][] = array(
                    'report_text' => 
                        preg_replace(
                            '/((http|https):\/\/)?[\w]+([\-\.]{1}[\w]+)*\.[a-z]{2,5}(\/)?[\w\d\?\/\.\=]*/',
                            '<a target="_blank" href="$0">$0</a>',
                            (isset($data['text']))?$data['text']:''
                        ),
                    'report_type' => (int)$type,
                    'spent_time' => (int)$data['time']
                    
                );
            }
            
            if ($modelMonthreport->add($monthreportData)) {
                $actionResult->status(MYLS_ActionResult::OK);
                $actionResult->text('Отчет за месяц сохранен');
            } else {
                $actionResult->status(MYLS_ActionResult::ERROR);
                $actionResult->text('Ошибка при сохранении отчета за месяц. Проверьте введенные данные');
            }
        } else {
            $actionResult->status(MYLS_ActionResult::ERROR);
            $actionResult->text('Введенные данные некорректны');
        }

        return $actionResult;
    }
}

?>

 

Revise this Paste

Parent: 39338
Your Name: Code Language: