/**
  * @return \Phalcon\Http\ResponseInterface
  */
 public function indexAction()
 {
     $feusers = Feusers::find(array('conditions' => 'deleted=0 AND (usergroup = ?1 OR onspot=1)', 'bind' => array(1 => $this->config['onspotusergroup']), 'order' => 'last_name ASC'));
     $allUsers = Feusers::find(array('conditions' => 'deleted=0 AND usergroup > 1'));
     $users = array();
     $onspotUsers = array();
     foreach ($feusers as $feuser) {
         $isOnspot = false;
         $feuser->available = '<span class="onspot inactive"></span>';
         $onspotDates = $feuser->getOnspotdates();
         $onspot = '<span class="onspot inactive"></span>';
         $onspotTitle = ' title="Heute nicht vor Ort"';
         foreach ($onspotDates as $onspotdate) {
             if (date('d.m.') == date('d.m.', $onspotdate->tstamp)) {
                 $feuser->available = '<span class="onspot active"></span>';
                 $isOnspot = true;
             }
         }
         if ($isOnspot) {
             $onspotUsers[] = $feuser;
         } else {
             $users[] = $feuser;
         }
     }
     $mergedAndSortedUsers = array_merge($onspotUsers, $users);
     $environment = $this->config['application']['debug'] ? 'development' : 'production';
     $baseUri = $this->config['application'][$environment]['staticBaseUri'];
     $path = $baseUri . '/' . $this->view->language . '/feusers/update/';
     $this->view->setVar('path', $path);
     $this->view->setVar('feusers', $mergedAndSortedUsers);
     $this->view->setVar('allusers', $allUsers);
 }
 public function createAction()
 {
     if ($this->request->isPost() && $this->request->getPost('consultant')) {
         $feuser = Feusers::findFirstByUid($this->request->getPost('consultant'));
         $time = time();
         $message = new Messages();
         $message->assign(array('pid' => 0, 'tstamp' => $time, 'crdate' => $time, 'cruser_id' => 0, 'deleted' => 0, 'hidden' => 0, 'session' => $_SERVER['REMOTE_ADDR'], 'feuserid' => $this->request->hasPost('consultant') ? $this->request->getPost('consultant') : 0, 'message' => $this->request->hasPost('message') ? $this->request->getPost('message') : ' ', 'firstname' => $this->request->hasPost('firstname') ? $this->request->getPost('firstname') : ' ', 'lastname' => $this->request->hasPost('lastname') ? $this->request->getPost('lastname') : ' ', 'phone' => $this->request->hasPost('phone') ? $this->request->getPost('phone') : ' ', 'zip' => $this->request->hasPost('zip') ? $this->request->getPost('zip') : ' ', 'city' => $this->request->hasPost('city') ? $this->request->getPost('city') : ' ', 'farmer' => $this->request->hasPost('farmer') ? $this->request->getPost('farmer') : 0, 'termsagreed' => $this->request->hasPost('terms') ? $this->request->getPost('terms') : 0));
         if (!$message->save()) {
             $this->flash->error($feuser->getMessages());
         }
         $sendMessage = array('konto' => 2982, 'password' => md5('ihttomlin1979'), 'service' => 6078, 'text' => $message->message, 'encoding' => 0, 'from' => $message->phone, 'to' => $feuser->phone, 'timestamp' => 0, 'return' => 'text', 'httphead' => 1, 'action' => 'send');
         $this->sendMessage($sendMessage);
     }
 }
 public function oldstartAction()
 {
     $request = $this->request;
     if ($this->request->isPost()) {
         //Receiving the variables sent by POST
         $email = $this->request->getPost('username', 'email');
         $rawpassword = $this->request->getPost('password');
         //Find the user in the database
         $feusers = Feusers::findFirst(array("email = :email: AND deleted=0 AND hidden=0", "bind" => array('email' => $email)));
         $checkedPasswords = $this->checkPassword($feusers->password, $rawpassword);
         if ($checkedPasswords != false) {
             $this->_registerSession($feusers);
             $this->flashSession->success($this->translate('welcome') . $feusers->username);
             //Forward to the 'invoices' controller if the user is valid
             $this->response->redirect("");
             $this->view->disable();
         } else {
             $this->flash->error('Wrong email/password');
         }
     }
     return $this->forward('session/index');
 }
Пример #4
0
 /**
  * Auths the user by his/her id
  *
  * @param int $id
  */
 public function authUserById($id)
 {
     $user = Feusers::findFirstById($id);
     if ($user == false) {
         throw new Exception('The user does not exist');
     }
     $this->checkUserFlags($user);
     $this->session->set('auth', array('uid' => $user->id, 'username' => $user->name, 'profile' => $user->profile->name));
 }
 public function uploadAction()
 {
     $time = time();
     $this->assets->addJs('js/vendor/addressesInit.js');
     $addressfoldersRecords = Feusers::find(array("conditions" => "deleted=0 AND hidden=0 AND usergroup = ?1", "bind" => array(1 => $this->session->get('auth')['usergroup']), "order" => "tstamp DESC"));
     $usergroups = Usergroups::find(array('conditions' => 'deleted=0 AND cruser_id <> 0'));
     $this->view->setVar('addressfolders', $addressfoldersRecords);
     $this->view->setVar('usergroups', $usergroups);
     $this->view->setVar('filehideshow', '');
     $this->view->setVar('maphideshow', 'hidden');
     if ($this->request->isPost()) {
         $this->view->setVar('filehideshow', 'hidden');
         $this->view->setVar('maphideshow', '');
         if ($this->request->hasFiles() == true) {
             $mimes = array('application/vnd.ms-excel', 'text/plain', 'text/csv', 'text/tsv');
             $fileArray = $this->request->getUploadedFiles();
             $file = $fileArray[0];
             if (in_array($file->getType(), $mimes)) {
                 $nameArray = explode('.', $file->getName());
                 $filetype = $nameArray[count($nameArray) - 1];
                 $tmpFile = '../app/cache/tmp/' . $time . '_' . $file->getName();
                 $file->moveTo($tmpFile);
                 $row = 0;
                 if (($handle = fopen($tmpFile, "r")) !== FALSE) {
                     $fileRowField = array();
                     if ($this->request->hasPost('firstRowFieldNames')) {
                         $data[$row] = fgetcsv($handle, 1000, $this->_divider[$this->request->getPost('divider')], $this->_dataWrap[$this->request->getPost('dataFieldWrap')]);
                         $fileRowField = array_values($data[$row]);
                     } else {
                         while ($row < 3) {
                             $data[$row] = fgetcsv($handle, 1000, $this->_divider[$this->request->getPost('divider')], $this->_dataWrap[$this->request->getPost('dataFieldWrap')]);
                             $row++;
                         }
                         for ($i = 0; $i < count($data[0]); $i++) {
                             $fileRowField[] = $data[0][$i] . '<br>' . $data[1][$i] . '<br>' . $data[2][$i];
                         }
                     }
                     fclose($handle);
                 } else {
                     die('Failed');
                 }
             }
             $this->view->setVar('divider', $this->request->getPost('divider'));
             $this->view->setVar('dataFieldWrap', $this->request->getPost('dataFieldWrap'));
             $this->view->setVar('tstamp', $time);
             $this->view->setVar('firstRowFieldNames', $this->request->hasPost('firstRowFieldNames') ? 1 : 0);
             $this->view->setVar('filename', $file->getName());
             $this->view->setVar('uploadfields', $fileRowField);
         } else {
             $time = time();
             $row = 0;
             $insStr = '';
             $addressesDBFieldMap = array(1 => 'first_name', 2 => 'last_name', 3 => 'title', 4 => 'salutation', 5 => 'email', 6 => 'company', 7 => 'phone', 8 => 'address', 9 => 'city', 10 => 'zip', 11 => 'userlanguage', 12 => 'gender', 13 => 'region', 14 => 'jobtitle', 15 => 'division', 16 => 'specialization', 18 => 'username', 19 => 'password', 20 => 'image', 21 => 'personellnumber');
             $addressesDBFieldTypeMap = array(1 => 'string', 2 => 'string', 3 => 'string', 4 => 'string', 5 => 'string', 6 => 'string', 7 => 'string', 8 => 'string', 9 => 'string', 10 => 'int', 11 => 'int', 12 => 'int', 13 => 'string', 14 => 'string', 15 => 'string', 16 => 'string', 18 => 'string', 19 => 'string', 20 => 'string', 21 => 'string');
             $basevals = array('pid' => 0, 'deleted' => 0, 'hidden' => 0, 'profileid' => 0, 'superuser' => 0, 'tstamp' => $time, 'crdate' => $time, 'cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->hasPost('usergroup') ? $this->request->getPost('usergroup') : 0, 'onspot' => $this->request->hasPost('onspot') ? 1 : 0);
             $indexArray = array();
             foreach ($this->request->getPost('adressFieldsMap') as $addressFieldIndex => $addressField) {
                 if (intval($addressField) != 0 && !is_nan(intval($addressField))) {
                     $indexArray[$addressFieldIndex] = $addressesDBFieldMap[$addressField];
                 }
             }
             foreach ($addressesDBFieldMap as $fieldIndex => $dbFields) {
                 if (!array_key_exists($dbFields, $indexArray)) {
                     if ($addressesDBFieldTypeMap[$fieldIndex] === 'string') {
                         $basevals[$dbFields] = '';
                     } else {
                         $basevals[$dbFields] = 0;
                     }
                 }
             }
             $tmpFile = '../app/cache/tmp/' . $this->request->getPost('time') . '_' . $this->request->getPost('filename');
             if (($handle = fopen($tmpFile, "r")) !== FALSE) {
                 if ($this->request->getPost('firstRowFieldNames') == 1) {
                     $data = fgetcsv($handle, 1000, $this->_divider[$this->request->getPost('divider')], $this->_dataWrap[$this->request->getPost('dataFieldWrap')]);
                 }
                 while (($data = fgetcsv($handle, 1000, $this->_divider[$this->request->getPost('divider')], $this->_dataWrap[$this->request->getPost('dataFieldWrap')])) !== FALSE) {
                     $feuser = new \messetool\Models\Feusers();
                     $fullname = '';
                     $imagename = ' ';
                     $imagenameName = '';
                     $imageNumber = 0;
                     $zipArrStrng = '';
                     foreach ($indexArray as $index => $indexKey) {
                         if ($indexKey == 'zip') {
                             $ins[$indexKey] = 0;
                             $zipArrStrng = $data[$index];
                         } elseif ($indexKey == 'first_name') {
                             $fullname = $data[$index];
                             $imagenameName = $data[$index];
                             $ins[$indexKey] = $data[$index];
                         } elseif ($indexKey == 'last_name') {
                             $fullname .= ' ' . $data[$index];
                             $imagenameName .= '_' . $data[$index];
                             $ins[$indexKey] = $data[$index];
                         } elseif ($indexKey == 'phone') {
                             $phone = str_replace(array(' ', '+49', '(', ')', '/', '-'), array('', '', '', '', '', ''), $data[$index]);
                             if (substr($phone, 0, 1) == '0') {
                                 $phone = '0049' . substr($phone, 1);
                             } else {
                                 $phone = '0049' . $phone;
                             }
                             $ins[$indexKey] = $phone;
                         } elseif ($indexKey == 'image') {
                             $imageNumber = $data[$index];
                         } else {
                             $ins[$indexKey] = $data[$index];
                         }
                     }
                     $insArray = array_merge($basevals, $ins);
                     $insArray['fullname'] = $fullname;
                     $insArray['image'] = $imageNumber . '_' . str_replace(' ', '_', $imagenameName) . '.jpg';
                     if ($this->request->hasPost('onspot')) {
                         $insArray['password'] = $this->auth->encryptPassword($insArray['personellnumber']);
                     }
                     $feuser->assign = $insArray;
                     $feuser->save();
                     $zipArray = explode(',', $zipArrStrng);
                     foreach ($zipArray as $zip) {
                         $lookup = new \messetool\Models\Feuser_zipcodes_lookup();
                         $lookup->assign(array('uid_local' => $feuser->uid, 'uid_foreign' => $zip));
                         $lookup->save();
                     }
                 }
                 fclose($handle);
                 unlink($tmpFile);
             }
             $this->response->redirect('backend/' . $this->view->language . '/feusers/');
             $this->view->disable();
         }
     } else {
         $this->view->setVar('divider', '');
         $this->view->setVar('dataFieldWrap', '');
         $this->view->setVar('tstamp', '');
         $this->view->setVar('filename', '');
         $this->view->setVar('firstRowFieldNames', '');
         $this->view->setVar('uploadfields', array());
     }
 }
    private function SearchName($queryStrng)
    {
        /*$queryStrng=$this->request->getPost('query');*/
        $suggestions = array("suggestions" => array());
        $suggestionQuery = Feusers::find(array('conditions' => 'usergroup > 1 AND fullname LIKE ?1 ORDER BY usergroup DESC', 'bind' => array(1 => '%' . $queryStrng . '%')));
        foreach ($suggestionQuery as $suggestion) {
            $onspot = '';
            $onspotTitle = '';
            if ($suggestion->onspot) {
                $onspotDates = $suggestion->getOnspotdates();
                $onspot = '<span class="onspot inactive"></span>';
                $onspotTitle = ' title="Heute nicht vor Ort"';
                foreach ($onspotDates as $onspotdate) {
                    if (date('d.m.') == date('d.m.', $onspotdate->tstamp)) {
                        $onspot = '<span class="onspot active"></span>';
                        $onspotTitle = ' title="Heute für Sie am Stand"';
                    }
                }
            }
            $info1 = $suggestion->onspot ? $suggestion->jobtitle : $suggestion->specialization;
            $info2 = $suggestion->onspot ? $suggestion->city : $suggestion->region;
            $suggestions['suggestions'][] = array('value' => $suggestion->first_name . ' ' . $suggestion->last_name, 'html' => '<div class="suggestion-item"' . $onspotTitle . '>' . $onspot . '
										<table>
											<tr>
												<td>
													<img src="' . $this->userImgExists($suggestion->image) . '" style="max-height:100px">
												</td>
												<td>
													<div class="">
														<span style="font-weight:bold">' . $suggestion->first_name . ' ' . $suggestion->last_name . '</span>,<br>
														' . $info1 . ',<br>
														' . $info2 . '<br><span class="contactButton small">SMS senden</span>
													</div>
												</td>
											</tr>
										</table>
									</div>', 'data' => $suggestion->uid);
        }
        return $suggestions;
    }