Beispiel #1
0
 public function newAction()
 {
     $this->_form = new Mybase_Form_People();
     $this->view->form = $this->_form;
     $formData = $this->getRequest()->getPost();
     if ($this->_request->isPost()) {
         if ($this->_form->isValid($formData)) {
             $company = new Model_Company();
             empty($formData['idcompany']) ? $formData['idcompany'] = $company->save($formData) : $formData['idcompany'];
             $unodorId = new Model_Login();
             $idlogin = $unodorId->save($formData);
             $formData['idlogin'] = $idlogin;
             $this->_modelUser->save($formData);
             $mail = new Model_Mail();
             $mail->prepare($formData)->generate(Model_Mail::INVITE)->send($formData['email']);
             $salt = 'ofsdmší&;516#@ešěýp-§)údjs861fds';
             $hash = md5($this->{$formData}['idcompany'] . $this->{$formData}['name'] . $this->{$formData}['surname'] . $this->{$formData}['email'] . $salt);
             $this->_flash('New User has been successfully created and E-mailed ***TODO*** - ' . $hash, 'done', true);
             return $this->_redirect('/people');
         } else {
             //$this->_flash('There is an errors in the form', 'error', false);
             $this->_form->populate($formData);
         }
     }
 }
Beispiel #2
0
 /**
  * Vraci pole ve tvaru "id => jmeno uzivatele"
  *
  * @param int $idaccount ID uctu
  * @param bool|array $companyData 	Seznam spolecnosti. Prebira bud pole s daty
  * 									(napr vystup metody {@link Model_Company::getFormSelect()}),
  * 									anebo hodnotu true, kdy v tomto pripade provede dotaz do DB.
  * @return array
  */
 public function getFormSelect($idaccount = null, $companyData = null)
 {
     $return = array();
     if (is_null($idaccount)) {
         $account = new Model_Account();
         $idaccount = $account->getId();
     }
     $users = $this->_dbTable->fetchAllEntry('idaccount = ' . $idaccount . '', array('iduser', 'name', 'surname', 'idcompany'));
     if (is_null($companyData)) {
         foreach ($users as $row) {
             $return[$row->iduser] = $row->surname . ' ' . $row->name;
         }
     } else {
         if (is_bool($companyData) and $companyData == true) {
             $companies = new Model_Company();
             $companyData = $companies->getFormSelect($idaccount);
         }
         foreach ($companyData as $idcompany => $company) {
             foreach ($users as $row) {
                 if ($idcompany == $row->idcompany) {
                     $return[$company][$row->iduser] = $row->surname . ' ' . $row->name;
                 }
             }
         }
     }
     return $return;
 }
Beispiel #3
0
 public function init()
 {
     $this->addElement('text', 'email', array('label' => "E-mail:", 'class' => 'input-text-big', 'required' => true, 'validators' => array(array('EmailAddress')), 'decorators' => $this->setInputDecorators()));
     $this->addElement('text', 'name', array('label' => "Name:", 'class' => 'input-text', 'required' => true, 'decorators' => $this->setInputDecorators('half left')));
     $this->addElement('text', 'surname', array('label' => "Surname:", 'class' => 'input-text', 'required' => true, 'decorators' => $this->setInputDecorators('half right')));
     $company = new Model_Company();
     $companyData = $company->getFormSelect(null, '--- Select ---');
     $this->addElement('select', 'idcompany', array('label' => "Company:", 'multiOptions' => $companyData, 'class' => 'input-select', 'required' => false, 'allowEmpty' => false, 'validators' => array('OneOfKind'), 'decorators' => $this->setInputDecorators('clear idcompany', array('Create', array('desc' => 'Create', 'class' => 'company-select')))));
     $this->addElement('text', 'company', array('label' => "Company:", 'class' => 'input-text', 'required' => false, 'allowEmpty' => false, 'validators' => array('OneOfKind'), 'decorators' => $this->setInputDecorators('clear company hide', array('Create', array('desc' => 'Select', 'class' => 'company-create')))));
     $this->addElement('textarea', 'note', array('label' => "Personal Note:", 'class' => 'input-textarea', 'rows' => 6, 'decorators' => $this->setInputDecorators()));
     $this->addElement('submit', 'save', array('value' => "Create User", 'class' => 'input-submit', 'decorators' => $this->setSubmitDecorators('people')));
 }
Beispiel #4
0
 public function init()
 {
     $this->addElement('text', 'name', array('label' => "Project name:", 'class' => 'input-text-big', 'required' => true, 'validators' => array(array('stringLength', false, array(3, 100))), 'decorators' => $this->setInputDecorators()));
     $this->addElement('textarea', 'description', array('label' => "Description:", 'class' => 'input-textarea', 'rows' => 6, 'decorators' => $this->setInputDecorators(), 'required' => true));
     $user = new Model_UserMeta();
     $company = new Model_Company();
     $companyData = $company->getFormSelect(null, '--- None ---');
     $this->addElement('select', 'iduser', array('label' => "Project leader:", 'multiOptions' => $user->getFormSelect(null, $companyData), 'class' => 'input-select', 'decorators' => $this->setInputDecorators(), 'required' => true));
     $this->addElement('select', 'idcompany', array('label' => "Client company:", 'multiOptions' => $companyData, 'class' => 'input-select', 'decorators' => $this->setInputDecorators()));
     $this->addElement('file', 'img', array('label' => "Image:", 'class' => 'input-file', 'decorators' => $this->setFileDecorators()));
     $this->addElement('submit', 'save', array('value' => "Create project", 'class' => 'input-submit', 'decorators' => $this->setSubmitDecorators('project')));
 }
Beispiel #5
0
 public function init()
 {
     $this->addElement('text', 'mail', array('label' => "E-mail:", 'class' => 'input-text', 'required' => true, 'validators' => array(array('EmailAddress')), 'decorators' => $this->setInputDecorators()));
     $company = new Model_Company();
     $companyData = $company->getFormSelect(null);
     $this->addElement('select', 'idcompany', array('label' => "Company:", 'multiOptions' => $companyData, 'class' => 'input-select', 'required' => true, 'decorators' => $this->setInputDecorators()));
     $this->addElement('text', 'mobile', array('label' => "Mobile:", 'class' => 'input-text', 'decorators' => $this->setInputDecorators('half left')));
     $this->addElement('text', 'work', array('label' => "Office:", 'class' => 'input-text', 'decorators' => $this->setInputDecorators('half left')));
     $this->addElement('text', 'home', array('label' => "Home:", 'class' => 'input-text', 'decorators' => $this->setInputDecorators('half left')));
     $this->addElement('text', 'im', array('label' => "IM:", 'class' => 'input-text', 'decorators' => $this->setInputDecorators('half left')));
     $this->addElement('select', 'imservice', array('label' => "", 'multiOptions' => array('msn' => 'MSN', 'icq' => 'ICQ', 'aol' => 'AOL'), 'class' => 'input-select', 'decorators' => $this->setInputDecorators('left')));
     $this->addElement('submit', 'save', array('value' => "Edit", 'class' => 'input-submit', 'decorators' => $this->setSubmitDecorators('people')));
 }
Beispiel #6
0
 public function action_delete($id = null)
 {
     is_null($id) and Response::redirect('companies');
     if ($company = Model_Company::find($id)) {
         $company->delete();
         Session::set_flash('success', 'Deleted company #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete company #' . $id);
     }
     Response::redirect('companies');
 }
Beispiel #7
0
 public function action_print($id = null, $month = null, $year = null)
 {
     parent::has_access("print_salary_statement");
     (is_null($id) or is_null($month) or is_null($year)) and Response::redirect('salaries');
     $data['rename'] = Model_Rename::find('first');
     $data['company'] = Model_Company::find('first', array('where' => array('city' => "Bangalore")));
     $data['employee'] = Model_Employee::find('first', array('where' => array('id' => $id)));
     if (!($data['salary'] = Model_Salary::find('first', array('where' => array(array('employee_id' => $id), array('month' => $month), array('year' => $year)))))) {
         Session::set_flash('error', 'Could not find salary #' . $id);
         Response::redirect('salaries');
     }
     $data['fytd'] = $this->findFYTD($id, $month, $year);
     return Response::forge(View::forge('salaries/payslip', $data));
 }