public function genformAction()
 {
     $generic = new Model_Generic();
     $table = $this->_getParam('tbl');
     /***$protected_tables = array("users","merchandisers","outlets","agents","activity_logs","users_access");
     
     		if(in_array($table,$protected_tables) && $authsession->user_access != 1){
     			$this->_redirect('/index/');
     			//$this->view->disable_input = 1;
     		}
     
     		if(in_array($table,$protected_tables)){
     			$this->view->disable_input = 1;
     		}***/
     //process form
     if ($_POST) {
         $data = $_POST;
         $save = $generic->insertData($table, $data);
         $this->view->saveMsg = array('success', 'Successfully Saved.');
         $this->_redirect('/encoder/genform/tbl/' . $table);
     }
     $list = $generic->getData($table, null, "ID", null);
     $paginator = Zend_Paginator::factory($list);
     $curPage = $this->_getParam('page', 1);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($curPage);
     $this->view->list = $paginator;
     $this->view->table = $table;
     $generic_call = $generic->genericForm($table);
     $this->view->genform = $generic_call;
 }
 public function userdisplayAction()
 {
     $user = new Model_User();
     $generic = new Model_Generic();
     if ($_POST) {
         $advdep = str_replace(array('-', '+'), '', $_POST['StoreCredits']);
         unset($_POST['StoreCredits']);
         if (is_numeric($advdep) && $advdep != 0) {
             $advdep = isset($_POST['selAD']) && $_POST['selAD'] == 'add' ? $advdep : $advdep * -1;
             $AdvanceDepositUsageHistoryData = array();
             $AdvanceDepositUsageHistoryData['EventDate'] = date('Y-m-d H:i:s');
             $AdvanceDepositUsageHistoryData['Event'] = 'Advance Deposit';
             $AdvanceDepositUsageHistoryData['Amount'] = $advdep;
             $AdvanceDepositUsageHistoryData['TransactionID'] = 'N/A';
             $AdvanceDepositUsageHistoryData['SiteUserID'] = $_POST['UserID'];
             $generic->insertData('AdvanceDepositUsageHistory', $AdvanceDepositUsageHistoryData);
             $_POST['StoreCredits'] = $_POST['StoreCreditsBeforeSubmit'] + $advdep;
         }
         unset($_POST['StoreCreditsBeforeSubmit']);
         unset($_POST['selAD']);
         $user->updateUserInfo($_POST);
         $user_id = $_POST['UserID'];
         $this->_redirect("/admin/userdisplay/ID/" . $user_id . '/?sysmsg=success');
     }
     if ($this->_getParam('ID')) {
         $user_id = isset($_POST['UserID']) ? $_POST['UserID'] : $this->_getParam('ID');
         $data = $user->oldSkul("select * from SiteUsers left join ResellerApplications on ResellerApplications.SiteUserID = SiteUsers.ID where SiteUsers.ID=" . $user_id . " and anAdmin != 1");
         $this->view->data = isset($data[0]) ? $data[0] : 0;
         $this->view->advanceDepositHistory = $generic->oldSkul("select * from AdvanceDepositUsageHistory where SiteUserID=" . $user_id . " order by EventDate");
     }
     $states = $user->getData('Shipping', '', 'State');
     $states_fin = array();
     foreach ($states as $row) {
         $states_fin[$row['ID']] = $row['State'];
     }
     $this->view->States = $states_fin;
 }
 public function menuAction()
 {
     $isAdmin = $this->isAdmin();
     $generic = new Model_Generic();
     $this->view->menus = $generic->getData("Menu");
     $menu_id = isset($_GET['mid']) ? $_GET['mid'] : 0;
     $this->view->menu_id = $menu_id;
     $menu_items = $generic->getData("MenuItems", "MenuID=" . $menu_id, "CustomOrder");
     $this->view->menu_items = $menu_items;
     if ($_POST) {
         if (isset($_POST['MenuEdit'])) {
             $menu_id = $_POST['MenuID'];
             $data = array();
             foreach ($_POST['Name'] as $row => $val) {
                 $data[$row]['MenuID'] = $menu_id;
                 $data[$row]['Name'] = $val;
             }
             foreach ($_POST['Link'] as $row => $val) {
                 $data[$row]['Link'] = $val;
             }
             foreach ($_POST['CustomOrder'] as $row => $val) {
                 $data[$row]['CustomOrder'] = $val;
             }
             $delete = $generic->oldSkul("delete from MenuItems where MenuID = " . $menu_id, false);
             foreach ($data as $updatemenu) {
                 $generic->insertData("MenuItems", $updatemenu);
             }
             $this->_redirect('/page/menu/?mid=' . $_POST['MenuID']);
         }
         if (isset($_POST['MenuAdd'])) {
             unset($_POST['MenuAdd']);
             $save = $generic->insertData("MenuItems", $_POST);
             if ($save) {
                 $this->_redirect('/page/menu/?mid=' . $_POST['MenuID']);
             }
         }
     }
     if (isset($_GET['mitid'])) {
         $generic->oldSkul("delete from MenuItems where ID = " . $_GET['mitid'], false);
         $this->_redirect('/page/menu/?mid=' . $menu_id);
     }
 }