示例#1
0
 /**
  * Pantalla para despues del inicio de sesi�n
  */
 public function indexAction()
 {
     $this->view->contentTitle = 'Sourcing China';
     $this->view->userLog = $userLog = UserLogQuery::create()->whereAdd(UserLog::ID_USER, $this->getUser()->getIdUser())->addDescendingOrderBy(UserLog::TIMESTAMP)->findOne();
     $this->view->user = $user = UserQuery::create()->findByPK($this->getUser()->getIdUser());
     //die(print_r($user));
     $this->view->setTpl('Home');
 }
示例#2
0
 /**
  * Metodo que autentica si existe el usuario y la contrase�a en la base de datos de lo contrario tira una excepcion.
  * ademas si existe guarda una variable en sesion la cual es util para saber si el usuario ya ha sido autenticado.
  * @param string $username Nombre de usuario
  * @param string $password Password
  * @return User $user
  * @throws Exception Si no existen coincidencias en el usuario/password
  */
 public function authenticate($username, $password)
 {
     try {
         $user = UserQuery::create()->whereAdd(User::USERNAME, $username)->whereAdd(User::PASSWORD, $password, UserQuery::EQUAL, null, UserQuery::PASSWORD)->findOne();
         if (!$user instanceof User) {
             throw new AuthException("Usuario y/o clave inv�lidos");
         }
         if ($user->getStatus() == 0) {
             throw new AuthException("Usuario desactivado");
         }
         $userLog = UserLogFactory::createFromArray(array('id_user' => $user->getIdUser(), 'event_type' => UserLog::LOGIN, 'ip' => $this->getRequest()->getServer("REMOTE_ADDR"), 'id_responsible' => $user->getIdUser(), 'timestamp' => null, 'note' => 'Inicio de sesi�n'));
         $this->userLogCatalog->create($userLog);
         return $user;
     } catch (AuthException $e) {
         if ($username != null) {
             $user = UserQuery::create()->whereAdd(User::USERNAME, $username)->findOne();
             if ($user instanceof User) {
                 $userLog = UserLogFactory::createFromArray(array('id_user' => $user->getIdUser(), 'event_type' => UserLog::FAILED_LOGIN, 'ip' => $this->getRequest()->getServer("REMOTE_ADDR"), 'id_responsible' => $user->getIdUser(), 'timestamp' => null, 'note' => 'Fall�, inicio de sesi�n'));
                 $this->userLogCatalog->create($userLog);
             }
         }
         throw $e;
     }
 }
示例#3
0
 /**
  * 
  */
 public function getListResultsAction()
 {
     $params = $this->getRequest()->getParams();
     if (!empty($params['username'])) {
         $params['username'] = '******' . $params['username'] . '%';
     }
     $users = UserQuery::create()->filter($params)->page($params['page'], $this->getMaxPerPage())->find();
     while ($user = $users->read()) {
         $user->setName(utf8_encode($user->getName()));
         $user->setLastName(utf8_encode($user->getLastName()));
         $user->setSecondName(utf8_encode($user->getSecondName()));
     }
     die(json_encode($users->toArray()));
 }
示例#4
0
 public function salesByProductAction()
 {
     $this->view->months = $this->getMonthsArray();
     $parentKey = $this->getRequest()->getParam('parent-key');
     $abcLimits = RestockPurchaseAbcClassQuery::create()->find();
     $inventory = InventoryRotationQuery::create()->find()->generateRotation($abcLimits);
     $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $parentKey, BaseQuery::LIKE)->find();
     $rotationGenerator = new RotationGeneratorManager();
     $rotationByKeyMother = $rotationGenerator->generateRotationByKeyMother($inventory, $products)->getByIndex($parentKey);
     $targetPrices = $products->map(function (Product $product) {
         return array($product->getItemCode() => $product->getCost());
     });
     $statusNames = Product::$StatusFullName;
     $this->view->abc = $abc = RestockAbcClassQuery::create()->find();
     $items = $inventory->filterByKeysMother($parentKey);
     $this->view->items = $items->generateRotation($abcLimits);
     $priceHistory = array();
     $products->rewind();
     while ($product = $products->read()) {
         $productCostLogs = ProductCostLogQuery::create()->whereAdd(ProductCostLog::ID_PRODUCT, $product->getItemCode())->orderBy(ProductCostLog::ID_PRODUCT_COST_LOG, ProductCostLogQuery::DESC)->setLimit(10)->find();
         $i = 0;
         $priceHistory[$product->getItemCode()] = array();
         while ($productCostLog = $productCostLogs->read()) {
             $priceHistory[$product->getItemCode()][$i]['date'] = $productCostLog->getDate();
             $priceHistory[$product->getItemCode()][$i]['currency'] = $productCostLog->getIdCurrencyTo();
             $priceHistory[$product->getItemCode()][$i]['price'] = $productCostLog->getPriceTo();
             $priceHistory[$product->getItemCode()][$i]['notes'] = $productCostLog->getNotes();
             $priceHistory[$product->getItemCode()][$i]['user'] = UserQuery::create()->findByPK($productCostLog->getIdUser())->getFullName();
             $i++;
         }
     }
     $this->view->priceHistory = $priceHistory;
     $this->view->data = $this->getEditInformation($parentKey);
     $this->view->parentKey = $rotationByKeyMother;
     $this->view->targetPrices = $targetPrices;
     $this->view->products = $products->toArray();
     $this->view->statusNames = $statusNames;
     $this->view->customsTariffCodes = array("" => $this->i18n->_("Select a Customs Tariff Code")) + CustomsTariffCodeQuery::create()->actives()->find()->toCombo();
     $this->view->defaultShippings = $this->getDefaultShipping();
     $this->view->setTpl('Sales');
 }
 /**
  *
  */
 protected function trackingAction()
 {
     $id = $this->getRequest()->getParam('id');
     $proformaInvoice = ProformaInvoiceQuery::create()->findByPKOrThrow($id, $this->i18n->_("It does not exist the ProformaInvoice with id {$id}"));
     $this->view->proformaInvoiceLogs = ProformaInvoiceLogQuery::create()->whereAdd('id_proforma_invoice', $id)->find();
     $this->view->users = UserQuery::create()->find()->toCombo();
 }
示例#6
0
 /**
  *
  * @param NotificationType $notificationType
  * @return array
  */
 private function getEmails(NotificationType $notificationType)
 {
     $emails = new EmailCollection();
     $regexp = self::EMAIL_REGEXP;
     $notificationTypeCatalog = $this->getCatalog('NotificationTypeCatalog');
     $accessRoles = AccessRoleQuery::create()->whereAdd(AccessRole::ID_ACCESS_ROLE, $notificationTypeCatalog->getAllAccessRoles($notificationType->getIdNotificationType()), AccessRoleQuery::IN)->find();
     while ($accessRoles->valid()) {
         $accessRole = $accessRoles->read();
         $users = UserQuery::create()->whereAdd(User::ID_ACCESS_ROLE, $accessRole->getIdAccessRole())->whereAdd(User::NOTIFICATIONS, User::$ReceiveNotifications['Yes'])->actives()->find();
         while ($users->valid()) {
             $user = $users->read();
             $email = EmailQuery::create()->innerJoinPerson()->whereAdd('Person.id_person', $user->getIdPerson())->findOne();
             if (!$email instanceof Email) {
                 $eventDispatcher = $this->getEventDispatcherService();
                 $eventDispatcher->createUserMissingEmailNotification($user, ErrorEvent::MISSING_USER_EMAIL, $notificationType);
                 continue;
             } elseif (!preg_match($regexp, $email->getEmail())) {
                 // 					$eventDispatcher->createIncorectUserEmailNotification($user, ErrorEvent::INCORRECT_USER_EMAIL, $notificationType);
             } else {
                 $emails->append($email);
             }
         }
     }
     $emailsArray = array_values($emails->filter(function (Email $email) use($regexp) {
         return preg_match($regexp, $email->getEmail());
     })->toCombo());
     return array_unique($emailsArray);
 }
 /**
  *
  */
 protected function trackingAction()
 {
     $id = $this->getRequest()->getParam('id');
     $purchaseOrder = PurchaseOrderQuery::create()->findByPKOrThrow($id, $this->i18n->_("It does not exist the PurchaseOrder with id {$id}"));
     $this->view->purchaseOrderLogs = PurchaseOrderLogQuery::create()->whereAdd('id_purchase_order', $id)->find();
     $this->view->users = UserQuery::create()->find()->toCombo();
 }