Ejemplo n.º 1
0
 /**
  * Get edit group form
  * 
  * @param number $id
  */
 public static function getEditPage($id)
 {
     $app = \Slim\Slim::getInstance();
     $dao = new GroupDAO();
     $userDAO = new UserDAO();
     $app->expires(time());
     $item = $dao->fetch($id);
     if (empty($item)) {
         return $app->notFound();
     }
     $numbers = $dao->getNumbers($item->getId());
     $pager1 = new Pager(MAINURL . '/groups/edit/' . $item->getId(), 50);
     $pager1->setQueryMode('page1');
     $pager1->setPage($_GET['page1']);
     $pager2 = new Pager(MAINURL . '/groups/edit/' . $item->getId(), 50);
     $pager2->setQueryMode('page2');
     $pager2->setPage($_GET['page2']);
     $totalRegistered = 0;
     $totalUnregistered = 0;
     $numbersRegistered = array();
     $numbersUnregistered = array();
     $start1 = $pager1->getPageSize() * $pager1->getPage();
     $end1 = $start1 + $pager1->getPageSize();
     $start2 = $pager2->getPageSize() * $pager2->getPage();
     $end2 = $start2 + $pager2->getPageSize();
     $cntRegistered = 0;
     $cntUnregistered = 0;
     foreach ($numbers as $k => $v) {
         if (!empty($v['synced'])) {
             if ($cntRegistered >= $start1 && $cntRegistered < $end1) {
                 $numbersRegistered[$k] = $v;
             }
             $cntRegistered++;
             $totalRegistered++;
         } else {
             if ($cntUnregistered >= $start2 && $cntUnregistered < $end2) {
                 $numbersUnregistered[$k] = $v;
             }
             $cntUnregistered++;
             $totalUnregistered++;
         }
     }
     $pager1->setTotal($totalRegistered);
     $pager1->setCount(count($numbersRegistered));
     $pager2->setTotal($totalUnregistered);
     $pager2->setCount(count($numbersUnregistered));
     $senderDAO = new SenderDAO();
     $strong = \Strong\Strong::getInstance();
     $user = $strong->getUser();
     $senders = $senderDAO->getList(array(user_id => $user['id']));
     $app->view->set('senders', $senders);
     $app->view->set('menu', 'groups');
     $app->view->set('id', $id);
     $app->view->set('item', $item);
     $app->view->set('pager1', $pager1);
     $app->view->set('pager2', $pager2);
     $app->view->set('users', $userDAO->getList());
     $app->view->set('numbersRegistered', $numbersRegistered);
     $app->view->set('numbersUnregistered', $numbersUnregistered);
     $app->view->set('duplicates', $dao->getDuplicates($item->getId()));
     $app->render('groups/edit.twig.html');
 }