Example #1
0
 function getcount($userseq, $date)
 {
     try {
         $monthstart = monthstart($date);
         $monthend = monthend($date);
         global $TABLE;
         $sql = sprintf("\r\n\t\t\t\t SELECT * FROM %s A\r\n\t\t\t\t WHERE UserSeq='%s' AND AttendDt>='%s' AND AttendDt<='%s'\r\n\t\t\t\t", $this->tbl_userattendhistory, $userseq, $monthstart, $monthend);
         $list = $this->dbop->execSQL($sql);
         return count($list);
     } catch (Exception $e) {
     }
     return 0;
 }
Example #2
0
 public function getTodayCalory()
 {
     $userseq = $this->input->post("UserSeq");
     $prescriptdate = $this->input->post("PrescriptDate");
     try {
         global $TABLE;
         $monthst = monthstart($prescriptdate);
         $monthen = monthend($prescriptdate);
         $consumecal = $this->getConsumeCalory($userseq, $prescriptdate);
         $intakecal = $this->getIntakeCalory($userseq, $prescriptdate);
         $consumemonthlycal = $this->getMonthlyConsumeCalory($userseq, $prescriptdate);
         $intakemonthlycal = $this->getMonthlyIntakeCalory($userseq, $prescriptdate);
         // Intake Calory
         $where = "A.UserSeq='" . $userseq . "' AND A.Date='" . $prescriptdate . "'";
         $sql = sprintf("\r\n\t\t\tSELECT A.*, B.FoodName FROM %s A INNER JOIN %s B ON A.FoodSeq = B.Seq\r\n\t\t\tWHERE %s", $TABLE['userdailyfood'], $TABLE['food'], $where);
         $data = $this->dbop->execSQL($sql);
         $foodlist = array();
         foreach ($data as $d) {
             $foodlist[] = array("Seq" => $d->Seq, "IntakeKind" => $d->IntakeKind, "FoodName" => $d->FoodName, "Kcal" => $d->KCal, "Ea" => $d->Ea);
         }
         $calory = $intakecal - $consumecal;
         $monthlycalory = $intakemonthlycal - $consumemonthlycal;
         echo json_capsule(array('Response' => 'Success', 'TodayCalory' => $calory, 'TodayConsumeCalory' => $consumecal, 'TodayIntakeCalory' => $intakecal, 'ConsumeCalory' => $consumemonthlycal, 'IntakeCalory' => $intakemonthlycal, 'FoodList' => $foodlist));
     } catch (Exception $e) {
         echo json_capsule(array('Response' => 'Fail', 'RtMsg' => 'Failed to get today calory.', 'Error' => $e->getMessage()));
     }
 }