2017-06-21 20 views
0

如何从post方法获取值并在foreach循环中爆炸。如何从post方法获取值并在foreach循环中爆炸

public function generate_all_payslip() { 
    $data['title'] = "Generate All Payslip"; 
    $this->payroll_model->_table_name = "tbl_department"; //table name 
    $this->payroll_model->_order_by = "department_id"; 
    $all_dept_info = $this->payroll_model->get(); 
    // get all department info and designation info 
    $dataalldep = array(); 
    foreach ($all_dept_info as $v_dept_info) { 
     $dataalldep['all_department_info'][] = $this->payroll_model->get_add_department_by_id($v_dept_info->department_id); 
    } 
    foreach ($dataalldep['all_department_info'] as $keyemp=>$valemparray) { 
     $datae = array(); 
     foreach($valemparray as $k=>$v) { 
      $datae['flag'] = 1; 
      $datae['designations_id'] = $v->designations_id; 
      $this->input->post('gapsbtn', TRUE); 
      $dataee['payment_date'] = $this->input->post('payment_date', TRUE); 
      $datepaymentmades = explode("-",$dataee['payment_date']); 
      $currentyears = $datepaymentmades[0]; 
      $currentmonths = $datepaymentmades[1]; 
      $currentyear = $currentyears ; 
      $currentmonth = $currentmonths ; 
      $datae['payment_date'] = $currentyear."-".$currentmonth; 
      $datae['employee_info'] = $this->payroll_model->get_emp_salary_list($emp = NULL, $datae['designations_id']); 
      $basicwagessalaey = $datae['employee_info'][0]->basic_salary; 
      $gross = $datae['employee_info'][0]->house_rent_allowance + $datae['employee_info'][0]->medical_allowance + $datae['employee_info'][0]->special_allowance + $datae['employee_info'][0]->fuel_allowance + $datae['employee_info'][0]->phone_bill_allowance + $datae['employee_info'][0]->other_allowance; 
      $deduction = $datae['employee_info'][0]->tax_deduction + $datae['employee_info'][0]->provident_fund + $datae['employee_info'][0]->other_deduction; 
      $net_extra = $gross - $deduction; 
      $workingdayscurrentmonth = $this->countDays($currentyear,$currentmonth, array(0)); 
      $perdaysaaryperuser = $basicwagessalaey/30; 
      ### full day ### 
      $queryfullday = $this->db->query("SELECT count(attendance_id) AS present_days FROM `tbl_attendance` WHERE attendance_status='1' AND month(date) = $currentmonth and year(date) = $currentyear AND employee_id='".$data['employee_info'][0]->employee_id."'"); 
      $attendancecountarray = $queryfullday->result_array(); 
      $attendancecounting = $attendancecountarray[0]['present_days']; 
      //$attendancecounting = 24; 
      $data['attendancecounting'] = $attendancecountarray[0]['present_days']; 
      if ($attendancecounting == $workingdayscurrentmonth) { 
       $data['totalmonthwagesfullday'] = ($perdaysaaryperuser*30)+$perdaysaaryperuser; 
      } else { 
       if ($workingdayscurrentmonth == 27) { 
        $data['totalmonthwagesfullday'] = ($perdaysaaryperuser*$attendancecounting)+($perdaysaaryperuser*3); 
       } 
       if ($workingdayscurrentmonth == 26) { 
        $data['totalmonthwagesfullday'] = ($perdaysaaryperuser*$attendancecounting)+($perdaysaaryperuser*4); 
       } 
       if ($workingdayscurrentmonth == 25) { 
        $data['totalmonthwagesfullday'] = ($perdaysaaryperuser*$attendancecounting)+($perdaysaaryperuser*5); 
       } 
       if ($workingdayscurrentmonth == 24) { 
        $data['totalmonthwagesfullday'] = ($perdaysaaryperuser*$attendancecounting)+($perdaysaaryperuser*6); 
       } 
      } 
      ### half day ### 
      $queryhalfday = $this->db->query("SELECT count(attendance_id) AS present_days FROM `tbl_attendance` WHERE attendance_status='2' AND month(date) = $currentmonth and year(date) = $currentyear AND employee_id='".$data['employee_info'][0]->employee_id."'"); 
      $attendancecountarray_half = $queryhalfday->result_array(); 
      $attendancecounting_half = $attendancecountarray_half[0]['present_days']; 
      //$attendancecounting_half = 1; 
      $data['attendancecounting_half'] = $attendancecountarray_half[0]['present_days']; 
      $data['totalmonthwages_half'] = ($perdaysaaryperuser/2)*$attendancecounting_half; 
      ### leave day ### 
      $queryleave = $this->db->query("SELECT count(attendance_id) AS present_days FROM `tbl_attendance` WHERE attendance_status='3' AND month(date) = $currentmonth and year(date) = $currentyear AND employee_id='".$data['employee_info'][0]->employee_id."'"); 
      $attendancecountarray_leave = $queryleave->result_array(); 
      $attendancecounting_leave = $attendancecountarray_leave[0]['present_days']; 
      //$attendancecounting_leave = 2; 
      $data['attendancecounting_leave'] = $attendancecountarray_leave[0]['present_days']; 
      $data['totalmonthwages_leave'] = $perdaysaaryperuser*$attendancecounting_leave; 
      ### absent day ### 
      $queryabsent = $this->db->query("SELECT count(attendance_id) AS present_days FROM `tbl_attendance` WHERE attendance_status='0' AND month(date) = $currentmonth and year(date) = $currentyear AND employee_id='".$data['employee_info'][0]->employee_id."'"); 
      $attendancecountarray_absent = $queryabsent->result_array(); 
      $attendancecounting_absent = $attendancecountarray_absent[0]['present_days']; 
      //$attendancecounting_absent = 1; 
      $data['attendancecounting_absent'] = $attendancecountarray_absent[0]['present_days']; 
      $data['totalmonthwages_absent'] = $perdaysaaryperuser*$attendancecounting_absent; 
      ###################### 
      $querylastsalary = $this->db->query("SELECT * FROM `tbl_salary_payment` WHERE employee_id='".$data['employee_info'][0]->employee_id."' Order BY salary_payment_id desc LIMIT 1"); 
      $lastsalary = $querylastsalary->result_array(); 
      $paymentamountlastmonth = $lastsalary[0]['payment_amount']; 
      $data['totalmonthwage'] = ($data['totalmonthwagesfullday']+$data['totalmonthwages_half']+$net_extra)-($data['totalmonthwages_absent']); 
      if ($paymentamountlastmonth < 0) { 
       $data['totalmonthwages'] = $data['totalmonthwage']+$paymentamountlastmonth; 
      } else { 
       $data['totalmonthwages'] = $data['totalmonthwage']; 
      } 
      ########## insert into tbl_salary_payment ########## 
      if ($datae['employee_info'][0]->employee_id !="") { 
       $dbinsert = array(); 
       $dbinsert['employee_id'] = $datae['employee_info'][0]->employee_id; 
       $dbinsert['basic_salary'] = $datae['employee_info'][0]->basic_salary; 
       $dbinsert['house_rent_allowance'] = $datae['employee_info'][0]->house_rent_allowance; 
       $dbinsert['medical_allowance'] = $datae['employee_info'][0]->medical_allowance; 
       $dbinsert['special_allowance'] = $datae['employee_info'][0]->special_allowance; 
       $dbinsert['fuel_allowance'] = $datae['employee_info'][0]->fuel_allowance; 
       $dbinsert['phone_bill_allowance'] = $datae['employee_info'][0]->phone_bill_allowance; 
       $dbinsert['other_allowance'] = $datae['employee_info'][0]->other_allowance; 
       $dbinsert['tax_deduction'] = $datae['employee_info'][0]->tax_deduction;  
       $dbinsert['provident_fund'] = $datae['employee_info'][0]->provident_fund; 
       $dbinsert['other_deduction'] = $datae['employee_info'][0]->other_deduction; 
       $dbinsert['payment_for_month'] = $datae['payment_date']; 
       $dbinsert['payment_type'] = 'Cash Payment'; 
       $dbinsert['payment_date'] = date('Y-m-d H:i:s'); 
       $dbinsert['payment_amount'] = round($totalmonthwages); 
       $dbinsert['present'] = $attendancecounting; 
       $dbinsert['halfday'] = $attendancecounting_half; 
       $dbinsert['leave'] = $attendancecounting_leave; 
       $dbinsert['absent'] = $attendancecounting_absent; 
       $insertedid = $this->payroll_model->insertpayrolldata($dbinsert); 
       ####### insert into tbl_salary_payslip ### 
       $dbinsertpayslip = array(); 
       $dbinsertpayslip['payslip_number'] = date('Ymd'); 
       $dbinsertpayslip['salary_payment_id'] = $insertedid; 
       $this->payroll_model->insertpayslipdata($dbinsertpayslip); 
      } 
     } 
    }  
    $data['subview'] = $this->load->view('admin/payroll/generate_all_payslip', $data, TRUE); 
    $this->load->view('admin/_layout_main', $data); 
} 

错误与此代码只

$this->input->post('gapsbtn', TRUE); 
    $dataee['payment_date'] = $this->input->post('payment_date', TRUE); 
    $datepaymentmades = explode("-",$dataee['payment_date']); 
    $currentyears = $datepaymentmades[0]; 
    $currentmonths = $datepaymentmades[1]; 
    $currentyear = $currentyears ; 
    $currentmonth = $currentmonths ; 

如果我使用

$currentyear = date('Y'); 
    $currentmonth = date('m'); 

工作fine.but我想使用日期,我已经选择不当前系统日期 我如何更正此代码。目前我看到这个错误

本页面无法正常工作

example.com是目前无法处理此请求。
HTTP错误500

+0

建议我如何更正此代码 – LEARNER

+1

如果您还没有,请添加'error_reporting(E_ALL); ini_set('display_errors',1);'这应该有希望告诉你为什么你会得到你的错误。 – Rasclatt

回答

0

是否有任何具体的原因使用下面提到的行?

$datepaymentmades = explode("-",$dataee['payment_date']); 

或者你让我们知道你想用这个做什么。

如果你想要的月份,日期和年份比请检查下面。

$paymentDate = strtotime($dataee['payment_date']); 
$month = date("m",strtotime($paymentDate)); 
$year = date("Y",strtotime($paymentDate)); 
$day = date("d",strtotime($paymentDate)); 
+0

还是一样的错误 – LEARNER

+0

让我看看你的错误 –

+0

if iremove this $ this-> input-> post('gapsbt'',TRUE); $ dataee ['payment_date'] = $ this-> input-> post('payment_date',TRUE); $ datepaymentmades =爆炸(“ - ”,$ dataee ['payment_date']); $ currentyears = $ datepaymentmades [0]; $ currentmonths = $ datepaymentmades [1]; $ currentyear = $ currentyears; $ currentmonth = $ currentmonths;并使用$ currentyear = date('Y'); $ currentmonth = date('m');那么我可以打开页面,但我不想要系统日期我想要使用日期,我已经选择 – LEARNER