예제 #1
0
 public function addMemo(User $user, ShippingOption $shippingOption)
 {
     $now = new \DateTime();
     $memo = "{$user->getUsername()}於{$now->format('Y-m-d')}修改運費為{$shippingOption->getDescription()}";
     $this->memo = "{$this->memo}{$memo}<br>";
     return $this;
 }
예제 #2
0
 public function fetchPaidCompleted(User $user)
 {
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->select('auction')->from('WoojinStoreBundle:Auction', 'auction')->where($qb->expr()->andX($qb->expr()->eq('auction.createStore', ':createStoreId'), $qb->expr()->eq('auction.profitStatus', ':profitStatus')));
     $qb->setParameter('createStoreId', $user->getStore()->getId())->setParameter('profitStatus', Auction::PROFIT_STATUS_PAY_COMPLETE);
     return $qb->getQuery()->getResult();
 }
예제 #3
0
 public function findOneByDateAndUser(\DateTime $date, User $user)
 {
     $start = clone $date;
     $end = clone $date;
     $start->modify('first day of this month');
     $end->modify('last day of this month');
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->select('h')->from('WoojinStoreBundle:Holiday', 'h')->leftJoin('h.user', 'u')->leftJoin('u.store', 's')->where($qb->expr()->andX($qb->expr()->between('h.createAt', $qb->expr()->literal($start->format('Y-m-d 00:00:00')), $qb->expr()->literal($end->format('Y-m-d 23:59:59'))), $qb->expr()->eq('h.user', $user->getId())))->orderBy('s.sn', 'DESC');
     return $qb->getQuery()->getOneOrNullResult();
 }
예제 #4
0
 /**
  * @Route("/{id}/edit", requirements={"id"="\d+"}, name="admin_user_update")
  * @ParamConverter("user", class="WoojinUserBundle:User")
  * @Method("PUT")
  */
 public function updateAction(Request $request, User $user)
 {
     $em = $this->getDoctrine()->getManager();
     $user->setStore($em->find('WoojinStoreBundle:Store', $request->request->get('store')))->setRole($em->find('WoojinUserBundle:Role', $request->request->get('role')))->setUsername($request->request->get('username', $user->getUsername()))->setEmail($request->request->get('email', $user->getEmail()))->setMobil($request->request->get('mobil', $user->getMobil()))->setIsActive((int) $request->request->get('is_active') === 1);
     $em->persist($user);
     $em->flush();
     $session = $this->get('session');
     $session->getFlashBag()->add('success', $user->getUsername() . '修改完成');
     return $this->redirect($this->generateUrl('admin_role_index'));
 }
예제 #5
0
 public function getImgRelDir(User $user)
 {
     $dirParts = array();
     $dirParts[] = 'img';
     $dirParts[] = 'product';
     $dirParts[] = $user->getStore()->getSn();
     $dirParts[] = $this->brand ? $this->brand->getName() : 'NoBrand';
     $dirParts[] = $this->pattern ? $this->pattern->getName() : 'NoPattern';
     $dirParts[] = $this->sn;
     return '/' . implode('/', $dirParts);
 }
예제 #6
0
 protected function genCriteria(Request $request, User $user)
 {
     $criteria = $request->request->all();
     if ($user->getRole()->hasAuth('BSO_VIEW_ALL_PROFIT') && array_key_exists('stores', $criteria)) {
         $criteria['stores'] = $criteria['stores'];
     }
     if (!$user->getRole()->hasAuth('BSO_VIEW_ALL_PROFIT')) {
         $criteria['stores'] = $user->getStore()->getId();
     }
     return $criteria;
 }
예제 #7
0
 /**
  * 判斷該使用者是否具有對應操作權限
  * 
  * @param  Woojin\UserBundle\Entity\User    $user
  * @param  string  $targetName
  * @return boolean            
  */
 public function hasAuth($user, $targetName)
 {
     return $user instanceof User ? $user->getRole()->hasAuth($targetName) : false;
 }
예제 #8
0
 /**
  * 是否允許分派紅利
  *
  * 1. 競拍實體狀態是否為售出
  * 2. 競拍毛利狀態是否為已付清
  * 3. 操作者所屬店家是否和競拍刷入店家相同
  * 
  * @param  Woojin\UserBundle\Entity\User    $user [操作者]
  * @return boolean
  */
 public function isAllowedAssignProfit(User $user)
 {
     return Auction::STATUS_SOLD === $this->getStatus() && Auction::PROFIT_STATUS_PAY_COMPLETE === $this->getProfitStatus() && $user->getStore()->getId() === $this->getCreateStore()->getId();
 }
예제 #9
0
파일: Custom.php 프로젝트: jocoonopa/avenue
 /**
  * Is the custom belong to the given user?
  *
  * @param  \Woojin\UserBundle\Entity\User   $user
  * @return boolean
  */
 public function isBelongUserStore(User $user)
 {
     return $this->getStore()->getId() === $user->getStore()->getId();
 }
예제 #10
0
 /**
  * GenCriteria by request  and the auth user
  *
  * @param  \Symfony\Component\HttpFoundation\Request    $request
  * @param  \Woojin\UserBundle\Entity\User    $user
  * @return array
  */
 protected function genCreateCriteria(Request $request, User $user)
 {
     $criteria = array('mobil' => $request->get('mobil'), 'store' => $user->getStore());
     return array_filter($criteria, array($this, '_isNotNull'));
 }
예제 #11
0
 public function getConsignFromOurStore(User $user)
 {
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->select(array('g', 'o', 'p'))->from('WoojinGoodsBundle:GoodsPassport', 'g')->leftJoin('g.orders', 'o')->leftJoin('g.parent', 'p')->leftJoin('p.orders', 'po')->where($qb->expr()->andX($qb->expr()->eq('p.status', Avenue::GS_OTHERSTORE), $qb->expr()->eq('po.kind', Avenue::OK_FEEDBACK), $qb->expr()->eq('po.status', Avenue::OS_HANDLING), $qb->expr()->eq('SUBSTRING(p.sn, 1, 1)', $qb->expr()->literal($user->getStore()->getSn()))));
     return $qb->getQuery()->getResult();
 }
예제 #12
0
 /**
  * For the purpose of typeahead
  *
  * @param  Woojin\UserBundle\Entity\User   $user
  * @param  string $mobil
  * @return array
  */
 public function getTypeahead(User $user, $mobil)
 {
     $em = $this->getEntityManager();
     $qb = $em->createQueryBuilder();
     $qb->select('c')->from('WoojinOrderBundle:Custom', 'c')->where($qb->expr()->andX($qb->expr()->like('c.mobil', '?1'), $qb->expr()->eq('c.store', $user->getStore()->getId())));
     $qb->setParameter('1', "{$mobil}%");
     return $qb->getQuery()->getResult();
 }
예제 #13
0
 public function attachUpdatePaidAtMemo(User $updater, \DateTime $paidAt)
 {
     $now = new \DateTime();
     $attach = "原付款時間{$this->getPaidAt()->format('Y-m-d')},{$updater->getUsername()}於{$now->format('Y-m-d')}更新為{$paidAt->format('Y-m-d')}";
     $this->memo = "{$this->memo}{$attach}<br>";
     return $this;
 }
예제 #14
0
 /**
  * Is auction belong to the given user's store
  *
  * @param  \Woojin\UserBundle\Entity\User  User    $user
  * @return boolean
  */
 public function isAuctionBelongGivenUsersStore(User $user)
 {
     if (NULL === $this->getBsoStore()) {
         return false;
     }
     return $this->getBsoStore()->getId() === $user->getStore()->getId();
 }