示例#1
0
function milking(Feeding $feeding)
{
    if (!$feeding->hasMilking()) {
        return '';
    }
    return $feeding->getMilking() . ' mL';
}
 protected function executeInner(IWebRequest $request, IWebResponse $response, Feeding $feeding)
 {
     $whichBoob = $request->post('whichBoob', null);
     if (is_null($whichBoob)) {
         throw new Exception('Missing whichBoob');
     }
     $totalMinutes = $request->post('totalMinutes', 0);
     $whichBoob = strtolower($whichBoob);
     switch ($whichBoob) {
         case 'left':
             $feeding->setBreastLeft($totalMinutes);
             break;
         case 'right':
             $feeding->setBreastRight($totalMinutes);
             break;
         default:
             throw new Exception('Unknown boob ' . $whichBoob);
     }
 }
 protected function executeInner(IWebRequest $request, IWebResponse $response, Feeding $feeding)
 {
     $type = $request->post('type', null);
     if (is_null($type)) {
         throw new Exception('Missing type');
     }
     $amount = $request->post('amount', 0);
     if ($amount > 0) {
         switch (strtolower($type)) {
             case 'milk':
                 $type = Bottle::TYPE_MILK;
                 break;
             case 'formula':
                 $type = Bottle::TYPE_FORMULA;
                 break;
             default:
                 throw new Exception('Unknown type ' . $type);
         }
         $feeding->setBottle(new Bottle($type, $amount));
     }
 }
 protected function executeInner(IWebRequest $request, IWebResponse $response, Feeding $feeding)
 {
     $feeding->setMilking($request->post('amount', $feeding->getMilking()));
 }
 protected function executeInner(IWebRequest $request, IWebResponse $response, Feeding $feeding)
 {
     $feeding->setPee($request->post('pee', $feeding->getPee()));
     $feeding->setPoo($request->post('poo', $feeding->getPoo()));
 }
 protected function insert(Feeding $feeding)
 {
     DebugLog::log('1');
     $feeding->setId($this->uuidHelper->get());
     DebugLog::log('2');
     DebugLog::log('3');
     $this->dbFactory->getConnection()->update("insert into feedings set\n\t\t\t\t  `id`=:id\n\t\t\t\t, `date_time`=:date_time\n\t\t\t\t, `status`=:status\n\t\t\t\t, `breast_left`=:breast_left\n\t\t\t\t, `breast_right`=:breast_right\n\t\t\t\t, `milking`=:milking\n\t\t\t\t, `pee`=:pee\n\t\t\t\t, `poo`=:poo\n\t\t\t\t, `bottle`=:bottle\n\t\t\t", array('id' => $feeding->getId(), 'date_time' => $feeding->getDateTime()->format('Y-m-d H:i:s'), 'status' => $feeding->getStatus(), 'breast_left' => $feeding->getBreastLeft(), 'breast_right' => $feeding->getBreastRight(), 'milking' => $feeding->getMilking(), 'pee' => $feeding->getPee(), 'poo' => $feeding->getPoo(), 'bottle' => $feeding->hasBottle() ? $feeding->getBottle()->encode() : null));
     DebugLog::log('4');
 }