Пример #1
0
 public function indexAction()
 {
     $form = new ApplicationForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $application = new Application();
         //$form->setInputFilter($application->getInputFilter());
         $form->setData($request->getPost()->toArray());
         $addVal = $request->getPost('addsubmit');
         $subVal = $request->getPost('subsubmit');
         $mulVal = $request->getPost('mulsubmit');
         $divVal = $request->getPost('divsubmit');
         $ans = "";
         if ($form->isValid()) {
             $application->exchangeArray($form->getData());
             if (!empty($addVal)) {
                 $ans = $form->get('num1')->getValue() + $form->get('num2')->getValue();
             } elseif (!empty($subVal)) {
                 $ans = $form->get('num1')->getValue() - $form->get('num2')->getValue();
             } elseif (!empty($mulVal)) {
                 $ans = $form->get('num1')->getValue() * $form->get('num2')->getValue();
             } elseif (!empty($divVal)) {
                 $ans = $form->get('num1')->getValue() / $form->get('num2')->getValue();
             }
             return new ViewModel(array('form' => $form, 'val' => $ans));
         }
         // print_r($form->getMessages());
         return new ViewModel(array('form' => $form));
     } else {
         return new ViewModel(array('form' => $form));
     }
 }
Пример #2
0
 public function save(Entity\Empleado $empleado)
 {
     $data = array('id_tipo_empleado' => $empleado->getIdTipoEmpleado(), 'id_unidad' => $empleado->getIdUnidad(), 'id_mitrol' => $empleado->getIdmitrol(), 'id_rh' => $empleado->getIdRh(), 'activo' => $empleado->getActivo(), 'nombre' => $empleado->getNombre(), 'fecha_ingreso' => Application::transformDate($empleado->getFechaIngreso()), 'horario' => $empleado->getHorario(), 'campana' => $empleado->getCampana(), 'jefe' => $empleado->getJefe(), 'sueldo_diario' => $empleado->getSueldoDiario());
     $id = (int) $empleado->getId();
     if ($id == 0) {
         if (!$this->insert($data)) {
             return false;
         } else {
             return $this->getLastInsertValue();
         }
     } else {
         if (!$this->update($data, array('id' => $id))) {
             return false;
         } else {
             return $id;
         }
     }
 }
Пример #3
0
 public function __construct()
 {
     parent::__construct();
 }