Exemple #1
0
 public function createCase($member_id, $doctor_id, $file_id, $request)
 {
     $id = $this->dbmgr->getNewId("tb_member_case");
     $apply_hospital = parameter_filter($request["apply_hospital"]);
     $apply_date = parameter_filter($request["apply_date"]);
     $name = parameter_filter($request["name"]);
     $sexual = parameter_filter($request["sexual"]);
     $age = parameter_filter($request["age"]);
     $category = parameter_filter($request["category"]);
     $way = parameter_filter($request["way"]);
     $urgent = parameter_filter($request["urgent"]);
     $necessary = parameter_filter($request["necessary"]);
     $meeting_date = parameter_filter($request["meeting_date"]);
     $first_result = parameter_filter($request["first_result"]);
     $acresult = parameter_filter($request["result"]);
     $checking = parameter_filter($request["checking"]);
     $solution = parameter_filter($request["solution"]);
     $caution = parameter_filter($request["caution"]);
     $signature = parameter_filter($request["signature"]);
     $status = parameter_filter($request["status"]);
     $summary = parameter_filter($request["summary"]);
     $contact = parameter_filter($request["contact"]);
     $apply_department = parameter_filter($request["apply_department"]);
     $apply_doctor = parameter_filter($request["apply_doctor"]);
     $apply_history = parameter_filter($request["apply_history"]);
     $apply_situation = parameter_filter($request["apply_situation"]);
     $apply_report = parameter_filter($request["apply_report"]);
     $apply_procedure = parameter_filter($request["apply_procedure"]);
     $apply_first_result = parameter_filter($request["apply_first_result"]);
     $contact_tel = parameter_filter($request["contact_tel"]);
     $contact_address = parameter_filter($request["contact_address"]);
     $hospital = parameter_filter($request["hospital"]);
     $department = parameter_filter($request["department"]);
     $tel = parameter_filter($request["tel"]);
     $tac = parameter_filter($request["tac"]);
     $meeting_time = parameter_filter($request["meeting_time"]);
     $meeting_date_mon = getmon(strtotime($meeting_date));
     $dayshort = getDayShortName($meeting_date);
     $dayshorttac = $dayshort . "_" . $tac;
     $sql = "select d.duty_{$dayshorttac} duty,ifnull(dr.{$dayshorttac},0) `use`  from tb_doctor d\nleft join tb_doctor_reserve dr on d.id=dr.doctor_id and dr.first_day='{$meeting_date_mon}'\nwhere d.id={$doctor_id} ";
     $query = $this->dbmgr->query($sql);
     $result = $this->dbmgr->fetch_array($query);
     if ($result["duty"] <= $result["use"]) {
         return "FULLRESERVE";
     }
     $meetweek = getmonsun(strtotime($meeting_date));
     $mon = $meetweek["mon_str_t"];
     $sun = $meetweek["sun_str_t"];
     $sql = "select * from tb_order\nwhere doctor_id={$doctor_id} and status='T' and meeting_date>='{$mon} 0:0:0' and meeting_date<='{$sun} 23:59:59'";
     $query = $this->dbmgr->query($sql);
     $result = $this->dbmgr->fetch_array_all($query);
     if (count($result) > 0) {
         return "RESERVEINWEEK";
     }
     $sql = "select 1 from tb_order where doctor_id={$doctor_id} and meeting_date='{$meeting_date}' and meeting_time='{$meeting_time}'";
     $query = $this->dbmgr->query($sql);
     $result = $this->dbmgr->fetch_array_all($query);
     if (count($result) > 0) {
         return "RESERVED";
     }
     $sql = "INSERT INTO `tb_member_case`\n(`id`,\n`member_id`,`file_id`,`title`,`doctor_id`,`apply_hospital`,`apply_date`,\n`name`,`sexual`,`age`,`category`,`way`,`urgent`,`necessary`,`meeting_date`,\n`first_result`,`position`,`result`,`checking`,`solution`,`caution`,`signature`,`status`,`created_date`,\n`updated_date`,`summary`,`contact`,`apply_department`,`apply_doctor`,`apply_history`,`apply_situation`,\n`apply_report`,`apply_procedure`,`apply_first_result`,`contact_tel`,`contact_address`,`hospital`,`department`,`tel`,`meeting_time`)\nVALUES\n({$id},\n{$member_id},{$file_id},'申请单{$meeting_date}',{$doctor_id},'{$apply_hospital}',\n'{$apply_date}','{$name}','{$sexual}','{$age}','{$category}','{$way}','{$urgent}','{$necessary}',\n'{$meeting_date}','{$first_result}','{$position}','{$acresult}','{$checking}','{$solution}','{$caution}','{$signature}','T',\nnow(),now(),'{$summary}','{$contact}','{$apply_department}','{$apply_doctor}','{$apply_history}',\n'{$apply_situation}','{$apply_report}','{$apply_procedure}','{$apply_first_result}',\n'{$contact_tel}','{$contact_address}','{$hospital}','{$department}','{$tel}','{$meeting_time}');\n";
     $this->dbmgr->begin_trans();
     $this->dbmgr->query($sql);
     $uploadfiles = explode("<||>", $request["uploadfiles"]);
     $attid = $this->dbmgr->getNewId("tb_member_case_attachment");
     foreach ($uploadfiles as $value) {
         if ($value != "") {
             $uploadfile = explode("<~>", $value);
             $filesavename = parameter_filter($uploadfile[0]);
             $filename = parameter_filter($uploadfile[1]);
             $sql = "insert into tb_member_case_attachment (id,case_id,filesavename,filename)\n\t\t\t\tvalues ({$attid},{$id},'{$filesavename}','{$filename}')";
             $this->dbmgr->query($sql);
             $attid++;
         }
     }
     $case_id = $id;
     $sql = "select 1 from tb_doctor_reserve where doctor_id={$doctor_id} and first_day='{$meeting_date_mon}'";
     $query = $this->dbmgr->query($sql);
     $result = $this->dbmgr->fetch_array_all($query);
     if (count($result) == 0) {
         $sql = "insert into tb_doctor_reserve (doctor_id,first_day) values ({$doctor_id},'{$meeting_date_mon}')";
         $this->dbmgr->query($sql);
     }
     $sql = "select price from tb_doctor where id={$doctor_id} ";
     $query = $this->dbmgr->query($sql);
     $result = $this->dbmgr->fetch_array($query);
     $price = $result["price"];
     $id = $this->dbmgr->getNewId("tb_order");
     $order_no = $this->genOrderNo("PT");
     $sql = "insert into tb_order \n\t\t(id,member_id,case_id,price,submit_date,meeting_date,tac,status,\n\t\tcreated_date,created_user,updated_date,updated_user,\n\t\torder_no,doctor_id,meeting_time) values \n\t\t({$id},{$member_id},{$case_id},{$price},now(),'{$meeting_date}','{$tac}','T',\n\t\tnow(),1,now(),1,\n\t\t'{$order_no}',{$doctor_id},'{$meeting_time}' )";
     $this->dbmgr->query($sql);
     $sql = "update tb_doctor_reserve set {$dayshorttac}=ifnull({$dayshorttac},0)+1 \n\t\twhere doctor_id={$doctor_id} and first_day='{$meeting_date_mon}' ";
     $this->dbmgr->query($sql);
     $this->dbmgr->commit_trans();
     return "RIGHT" . $id;
 }
Exemple #2
0
        echo "NO_MEMBER";
        exit;
    } else {
        $type = $_REQUEST["type"];
        if ($type == "follow") {
            $memberMgr->followDoctor($member_id, $doctor_id);
        } elseif ($type == "unfollow") {
            $memberMgr->unfollowDoctor($member_id, $doctor_id);
        }
        echo "RIGHT";
        exit;
    }
} else {
    if ($member_id == 0) {
        $smarty->assign("follow", 0);
    } else {
        $follow = $memberMgr->isFollowDoctor($member_id, $doctor_id);
        $smarty->assign("follow", $follow);
    }
    $info = $doctorMgr->getDoctor($doctor_id);
    $smarty->assign("info", $info);
    $schedultarr = array();
    $time = time();
    for ($i = 0; $i < 4; $i++) {
        $schedultarr[] = getmonsun($time + $i * 86400 * 7);
    }
    $smarty->assign("schedule", $schedultarr);
    $reserve = $doctorMgr->getDoctorReserve($doctor_id, $schedultarr[0]["first_day"]);
    $smarty->assign("reserve", $reserve);
    $smarty->display(ROOT . '/templates/Doctor/doctor.html');
}