| xqd
@@ -22,11 +22,6 @@ class PatientsSheet implements ToCollection
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
- //todo 用同一个程序的话,excel的字段顺序要对应起来
|
|
|
- if ($row[0]=="孩子姓名")
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
|
|
|
//姓名
|
|
|
if ($row[2] == null)
|
| xqd
@@ -49,6 +44,7 @@ class PatientsSheet implements ToCollection
|
|
|
'created_at' => date('Y-m-d H:i:s',time()),
|
|
|
'balance' => 0
|
|
|
]);
|
|
|
+ \Log::info('新增用户'.$new_user['id']);
|
|
|
}else{
|
|
|
$new_user['id'] = User::where('phone',$row[1])->value('id');
|
|
|
}
|
| xqd
@@ -64,7 +60,7 @@ class PatientsSheet implements ToCollection
|
|
|
{
|
|
|
$patients_info['sex'] = 0;
|
|
|
}else{
|
|
|
- if ($row[4] == "男")
|
|
|
+ if ($row[5] == "男")
|
|
|
{
|
|
|
$patients_info['sex'] = 1;
|
|
|
}else{
|
| xqd
@@ -81,8 +77,34 @@ class PatientsSheet implements ToCollection
|
|
|
}else{
|
|
|
$patients_info['phone'] = $row[1];
|
|
|
}
|
|
|
- //todo 患者生日没有导入
|
|
|
+ if ($row[3])
|
|
|
+ {
|
|
|
+ $patients_info['birthday'] = self::excelTime($row[3]);
|
|
|
+ }else{
|
|
|
+ $patients_info['birthday'] = self::excelTime(0);
|
|
|
+ }
|
|
|
Patient::create($patients_info);
|
|
|
}
|
|
|
}
|
|
|
+ static function excelTime($date, $time = false) {
|
|
|
+ if(function_exists('GregorianToJD')){
|
|
|
+ if (is_numeric( $date )) {
|
|
|
+ $jd = GregorianToJD( 1, 1, 1970 );
|
|
|
+ $gregorian = JDToGregorian( $jd + intval ( $date ) - 25569 );
|
|
|
+ $date = explode( '/', $gregorian );
|
|
|
+ $date_str = str_pad( $date [2], 4, '0', STR_PAD_LEFT )
|
|
|
+ ."-". str_pad( $date [0], 2, '0', STR_PAD_LEFT )
|
|
|
+ ."-". str_pad( $date [1], 2, '0', STR_PAD_LEFT )
|
|
|
+ . ($time ? " 00:00:00" : '');
|
|
|
+ return $date_str;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $date=$date>25568?$date+1:25569;
|
|
|
+ /*There was a bug if Converting date before 1-1-1970 (tstamp 0)*/
|
|
|
+ $ofs=(70 * 365 + 17+2) * 86400;
|
|
|
+ $date = date("Y-m-d",($date * 86400) - $ofs).($time ? " 00:00:00" : '');
|
|
|
+ }
|
|
|
+// dd($date);
|
|
|
+ return $date;
|
|
|
+ }
|
|
|
}
|