Esempio n. 1
0
 public function executeUpdateTimesheetItemComment($request)
 {
     $this->backAction = $this->getContext()->getUser()->getFlash('actionName');
     $this->getContext()->getUser()->setFlash('actionName', $this->backAction);
     $timesheetId = $request->getParameter('timesheetId');
     $activityId = $request->getParameter('activityId');
     $projectId = $this->getProjectId($activityId);
     $date = $request->getParameter('date');
     $comment = $request->getParameter('comment');
     $csrfToken = $request->getParameter('csrfToken');
     $form = new TimesheetFormToImplementCsrfTokens();
     if ($form->getCSRFToken() != $csrfToken) {
         return sfView::NONE;
     }
     $employeeId = $request->getParameter('employeeId');
     $dao = new TimesheetDao();
     $timesheetItem = $dao->getTimesheetItemByDateProjectId($timesheetId, $employeeId, $projectId, $activityId, $date);
     if ($timesheetItem[0]->getTimesheetItemId() == null) {
         $newTimesheetItem = new TimesheetItem();
         $newTimesheetItem->setTimesheetId($timesheetId);
         $newTimesheetItem->setDate($date);
         $newTimesheetItem->setComment(trim($comment));
         $newTimesheetItem->setProjectId($projectId);
         $newTimesheetItem->setEmployeeId($employeeId);
         $newTimesheetItem->setActivityId($activityId);
         $resultItem = $dao->saveTimesheetItem($newTimesheetItem);
     } else {
         $timesheetItem[0]->setComment(trim($comment));
         $resultItem = $dao->saveTimesheetItem($timesheetItem[0]);
     }
     return $this->renderText($resultItem->getTimesheetItemId());
 }
 /**
  *
  * @param <type> $request
  * @return <type>
  */
 public function execute($request)
 {
     $this->setLayout(false);
     sfConfig::set('sf_web_debug', false);
     sfConfig::set('sf_debug', false);
     $csrfToken = $request->getParameter('csrfToken');
     $form = new TimesheetFormToImplementCsrfTokens();
     if ($form->getCSRFToken() != $csrfToken) {
         return sfView::NONE;
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
     }
     $customerName = $request->getParameter('customerName');
     $description = $request->getParameter('description');
     $customer = new Customer();
     $customer->setName($customerName);
     $customer->setDescription($description);
     $customer->save();
     $array = array('id' => $customer->getCustomerId());
     return $this->renderText(json_encode($array));
 }