Пример #1
0
 public function weeklyCostsAction()
 {
     $result = array();
     $result["laborCost"] = '';
     $result["foodCost"] = '';
     $dateFrom = $this->getRequest()->getParam('dateFrom');
     $dateTo = $this->getRequest()->getParam('dateTo');
     $idUser = $this->getRequest()->getParam('idUser');
     $modelWeeklyCosts = new Default_Model_WeeklyCosts();
     $selectFind = $modelWeeklyCosts->getMapper()->getDbTable()->select()->where('dateFrom = ?', $dateFrom)->where('dateTo = ?', $dateTo)->where('idUser = ?', $idUser);
     $modelWeeklyCosts->fetchRow($selectFind);
     if ($modelWeeklyCosts->getId() !== NULL) {
         //existing weekly cost added in the database
         $result["idWeeklyCosts"] = $modelWeeklyCosts->getId();
         $result["laborCost"] = $modelWeeklyCosts->getLaborCost();
         $result["foodCost"] = $modelWeeklyCosts->getFoodCost();
     }
     echo Zend_Json_Encoder::encode($result);
 }