Beispiel #1
0
 public function __construct(array $params = array())
 {
     $params['collection'] = 'billrun';
     $params['db'] = 'billrun';
     parent::__construct($params);
     $this->search_key = array('billrun_key', 'aid');
 }
Beispiel #2
0
 public function __construct(array $params = array())
 {
     $params['collection'] = 'balances';
     $params['db'] = 'balances';
     parent::__construct($params);
     $this->search_key = "stamp";
 }
Beispiel #3
0
 public function getData($filter_query = array())
 {
     $resource = parent::getData();
     $ret = array();
     foreach ($resource as $item) {
         $item['roles'] = implode(", ", $item['roles']);
         $ret[] = $item;
     }
     return $ret;
 }
Beispiel #4
0
 public function getData($filter_query = array())
 {
     $resource = parent::getData($filter_query);
     $ret = array();
     foreach ($resource as $item) {
         if ($current_plan = $this->getDBRefField($item, 'current_plan')) {
             $item['current_plan'] = $current_plan['name'];
         }
         $ret[] = $item;
     }
     $this->_count = $resource->count(false);
     return $ret;
 }
 /**
  * If user is just waiting, delete the wait
  * If user is in match already, this will end the current match,
  * and the opponent will win with official result 10:0
  * @return multitype:string
  */
 public function endMatch()
 {
     $team = Session::get('team');
     if (empty($team)) {
         return array('error' => 'You are not logged in!');
     }
     // check if user is in some match
     $match = MatchModel::getActiveMatchForTeam($team->id);
     if (!empty($match)) {
         $match = $match[0];
         // run this as transaction
         DB::transaction(function () use($match, $team) {
             // finish this match as 10:0 (or 0:10)
             MatchModel::finishMatchOfficially($match->id, $team->id != $match->home_id);
             // update the teams goals counters, so our team concedes 10 goals
             MatchModel::updateTeamGoals($match->home_id, $match->away_id, $team->id == $match->away_id ? 10 : 0, $team->id == $match->home_id ? 10 : 0);
         });
     } else {
         // user is not in match, delete him from the waiting
         TableModel::removeTeamFromWaiting($team->id);
     }
     return array('status' => 'ok');
 }
Beispiel #6
0
 public function getFilterFields()
 {
     $filter_fields = array('type' => array('key' => 'source', 'db_key' => 'source', 'input_type' => 'text', 'comparison' => 'contains', 'display' => 'Type', 'default' => ''));
     return array_merge($filter_fields, parent::getFilterFields());
 }
            break;
        case 'add_bookmark':
            $db_update_success = BookmarkManager::addRecord($title, $url);
            break;
        case 'delete_by_id':
            $db_delete_success = BookmarkManager::deleteRecord($id);
            break;
    }
    $page_title = 'Bookmarks';
    $search_target = 'bookmarks';
    $bookmark_data = BookmarkManager::getAllRecords();
    $alt_menu = getAddButton() . getSearchButton();
    $searchModel = new SearchModel($search_target);
    $addModel = new AddModel('Add', 'add_bookmark');
    $addModel->addRow('title', 'Title');
    $addModel->addRow('url', 'URL');
    $bookmarkModel = new TableModel('', $search_target);
    /*$bookmarkModel->addRow ( array (
    			TableView2::createCell ('site', 'Site', 'th'),
    			TableView2::createCell ()
    		));*/
    while (($bookmark_row = mysql_fetch_array($bookmark_data)) != null) {
        $target = $sbookmark ? ' target="_blank"' : '';
        $bookmarkModel->addRow(array(TableView2::createCell('bookmark', '<a href="' . $bookmark_row['url'] . '" ' . $target . '>' . $bookmark_row['title'] . '</a>'), TableView2::createEdit($bookmark_row['BOOKMARK_ID'])));
    }
    $views_to_load = array();
    $views_to_load[] = ' ' . AddView2::render($addModel);
    $views_to_load[] = ' ' . SearchView::render($searchModel);
    $views_to_load[] = ' ' . TableView2::render($bookmarkModel);
    include $relative_base_path . 'views/_generic.php';
}
Beispiel #8
0
 public static function mergeOptions(array $array1, array $array2)
 {
     try {
         return parent::mergeOptions($array1, $array2);
     } catch (\InvalidArgumentException $e) {
         throw new ApiTableModelException($e->getMessage(), 0, $e);
     }
 }
Beispiel #9
0
 public function applyFilter($filter_field, $value)
 {
     if ($filter_field['comparison'] == 'special') {
         if ($filter_field['input_type'] == 'boolean') {
             if (!is_null($value) && $value != $filter_field['default']) {
                 $rates_coll = Billrun_Factory::db()->ratesCollection();
                 $unrated_rate = $rates_coll->query("key", "UNRATED")->cursor()->setReadPreference(Billrun_Factory::config()->getConfigValue('read_only_db_pref'))->current()->createRef($rates_coll);
                 $month_ago = new MongoDate(strtotime("1 month ago"));
                 return array('$or' => array(array('arate' => $unrated_rate), array('sid' => false), array('$and' => array(array('arate' => array('$exists' => true, '$nin' => array(false, $unrated_rate))), array('sid' => array('$exists' => true, '$ne' => false)), array('urt' => array('$lt' => $month_ago)), array('aprice' => array('$exists' => false))))));
             }
         }
     } else {
         return parent::applyFilter($filter_field, $value);
     }
 }
Beispiel #10
0
 public function getData($filter_query = array())
 {
     $resource = parent::getData($filter_query);
     $this->_count = $resource->count(false);
     return $resource;
 }
            break;
        case 'delete_by_id':
            $db_delete_success = BudgetManager::deleteRecurringRecord($id);
            break;
    }
    $page_title = 'Recurring | Budget';
    $alt_menu = getAddButton() . getBackButton();
    $addModel = new AddModel('Add', 'add_budget_item');
    $addModel->addRow('amount', 'Amount');
    $addModel->addRow('category', 'Category');
    $addModel->addRow('store', 'Store');
    $addModel->addRow('items', 'Items');
    $addModel->addRow('startdate', 'Start Date', 'CURRENT_TIMESTAMP');
    $addModel->addRow('enddate', 'End Date', '2037-12-31 23:59:59');
    // build recurring table model
    $recurringModel = new TableModel('Recurring items', 'recurring');
    $recurringModel->addRow(array(TableView2::createCell('amount', 'Amount', 'th'), TableView2::createCell('category', 'Category', 'th'), TableView2::createCell('store', 'Store', 'th'), TableView2::createCell('items', 'Items', 'th'), TableView2::createCell()));
    $recurring_items_data = BudgetManager::getAllRecurring();
    while (($recurring_items_row = mysql_fetch_array($recurring_items_data)) != null) {
        $amount = $recurring_items_row['amount'];
        $category = $recurring_items_row['category'];
        $recurringModel->addRow(array(TableView2::createCell('amount', format_currency($amount)), TableView2::createCell('category', $category), TableView2::createCell('store', $recurring_items_row['store']), TableView2::createCell('items', $recurring_items_row['items']), TableView2::createEdit($recurring_items_row['RECURRING_ID'], 'editRecurring.php')));
        $total_spent += $amount;
        $category_normalized = strtolower($category);
        $totals[$category_normalized] = isset($totals[$category_normalized]) ? $totals[$category_normalized] + $amount : $amount;
    }
    $views_to_load = array();
    $views_to_load[] = ' ' . AddView2::render($addModel);
    $views_to_load[] = ' ' . TableView2::render($recurringModel);
    include $relative_base_path . 'views/_generic.php';
}
Beispiel #12
0
 public function getFilterFields()
 {
     $filter_fields = array('type' => array('key' => 'source', 'db_key' => 'source', 'input_type' => 'multiselect', 'comparison' => '$in', 'display' => 'Type', 'values' => Billrun_Factory::config()->getConfigValue('admin_panel.log.source'), 'default' => array()));
     return array_merge($filter_fields, parent::getFilterFields());
 }
    $page_title = 'Receipt | Budget';
    $alt_menu = getAddButton() . getBackButton();
    // add Item form
    $addModel = new AddModel('Add', 'add_receipt_item');
    $addModel->addRow('item_name', 'Item');
    $addModel->addRow('amount', 'Amount');
    $addModel->addRow('qty', 'Qty', 1);
    $addModel->addRow('category', 'Category');
    $addModel->addRow('brand', 'Brand');
    $addModel->addRow('size', 'Size');
    $addModel->addRow('size_unit', 'Units');
    $addModel->addRow('sale', 'Sale');
    $addModel->addOptionBox('tax', 'Tax', ['13%', '0%']);
    $addModel->addRow('budget_id', 'budget_id', $id);
    // build items table model
    $itemsModel = new TableModel('Items', 'budget');
    $itemsModel->addRow(array(TableView2::createCell('total', 'total', 'th'), TableView2::createCell('qty', 'qty', 'th'), TableView2::createCell('tax', 'tax', 'th'), TableView2::createCell('amount', 'Amount', 'th'), TableView2::createCell('item_name', 'Item', 'th'), TableView2::createCell('category', 'Category', 'th'), TableView2::createCell('brand', 'Brand', 'th'), TableView2::createCell('size', 'Size', 'th'), TableView2::createCell('units', 'units', 'th'), TableView2::createCell('sale', 'sale', 'th'), TableView2::createCell()));
    while (($items_row = mysql_fetch_array($items)) != null) {
        $item_total = $items_row['amount'] * $items_row['qty'] * (1 + $items_row['tax']);
        $itemsModel->addRow(array(TableView2::createCell('total', format_currency($item_total)), TableView2::createCell('qty', $items_row['qty']), TableView2::createCell('tax', format_percent($items_row['tax'])), TableView2::createCell('amount', format_currency($items_row['amount'])), TableView2::createCell('item_name', $items_row['item_name']), TableView2::createCell('category', $items_row['category']), TableView2::createCell('brand', $items_row['brand']), TableView2::createCell('size', $items_row['size']), TableView2::createCell('units', $items_row['size_unit']), TableView2::createCell('sale', $items_row['sale']), TableView2::createEdit($items_row['BUDGET_ITEM_ID'], 'editItem.php')));
        $receipt_total += $item_total;
    }
    // build budget table model
    $budgetModel = new TableModel('', 'budget');
    $budgetModel->addRow(array(TableView2::createCell('total', 'Total', 'th'), TableView2::createCell('store', 'Store', 'th'), TableView2::createCell('date', 'Date', 'th')));
    $budgetModel->addRow(array(TableView2::createCell('amount', format_currency($receipt_total)), TableView2::createCell('store', $spending_history_data['store']), TableView2::createCell('date', $spending_history_data['date'])));
    $views_to_load[] = ' ' . AddView2::render($addModel);
    $views_to_load[] = ' ' . TableView2::render($budgetModel);
    $views_to_load[] = ' ' . TableView2::render($itemsModel);
    include $relative_base_path . 'views/_generic.php';
}
Beispiel #14
0
 public function __construct($connection, $tableName)
 {
     parent::__construct($connection, $tableName);
 }
Beispiel #15
0
 public function remove($params)
 {
     // first remove line from queue (collection) than from lines collection (parent)
     Billrun_Factory::db()->queueCollection()->remove($params);
     return parent::remove($params);
 }
Beispiel #16
0
 public function __construct(array $params = array())
 {
     $params['collection'] = Billrun_Factory::db()->events;
     parent::__construct($params);
     $this->search_key = "stamp";
 }
Beispiel #17
0
        case "signing_in":
            $ProfileModel = new ProfileModel($conn);
            $value = $ProfileModel->login_detail_check($_GET["usrid"], $_GET["pwd"], $_GET["comp"]);
            break;
        case "get_profile_data":
            $ProfileModel = new ProfileModel($conn);
            $value = $ProfileModel->get_profile_data();
            break;
        case "get_all_companies":
            $CompanyModel = new CompanyModel($conn);
            $value = $CompanyModel->get_all_companies();
            break;
        case "create_menu":
            $MenuModel = new MenuModel($conn);
            $value = $MenuModel->create_main_menu();
            break;
        case "get_table_default":
            $TableModel = new TableModel($conn, $_GET);
            $value = $TableModel->get_table();
            break;
        case "save_table_default":
            $EditTableModel = new EditTable($conn, $_GET, $_POST);
            $value = $EditTableModel->edit_table();
            break;
        case "input_check":
            $inputCheck = new InputCheck($conn);
            $value = $inputCheck->check();
            break;
    }
}
echo $value;
Beispiel #18
0
 public function applyFilter($filter_field, $value)
 {
     if ($filter_field['input_type'] == 'date' && is_array($filter_field['db_key'])) {
         if (is_string($value)) {
             $value = new MongoDate((new Zend_Date($value, null, new Zend_Locale('he_IL')))->getTimestamp());
             return array('$and' => array(array($filter_field['db_key'][0] => array($filter_field['comparison'][0] => $value), $filter_field['db_key'][1] => array($filter_field['comparison'][1] => $value))));
         }
     } else {
         return parent::applyFilter($filter_field, $value);
     }
 }
 public function __construct($adapter = null)
 {
     parent::__construct($adapter);
 }
Beispiel #20
0
 $addModel->addRow('selectTime-date', 'Date', '', 'YYYY-MM-DD');
 $addModel->addRow('selectTime-time', 'Time', '', 'HH:MM:SS');
 // build recurring table model
 $recurringModel = new TableModel('Recurring items', 'recurring');
 $recurringModel->addRow(array(TableView2::createCell('amount', 'Amount', 'th'), TableView2::createCell('category', 'Category', 'th'), TableView2::createCell('store', 'Store', 'th'), TableView2::createCell('items', 'Items', 'th')));
 $recurring_items_data = BudgetManager::getAllRecurringByMonth($year, $month);
 while (($recurring_items_row = mysql_fetch_array($recurring_items_data)) != null) {
     $amount = $recurring_items_row['amount'];
     $category = $recurring_items_row['category'];
     $recurringModel->addRow(array(TableView2::createCell('amount', format_currency($amount)), TableView2::createCell('category', $category), TableView2::createCell('store', $recurring_items_row['store']), TableView2::createCell('items', $recurring_items_row['items'])));
     $total_spent += $amount;
     $category_normalized = strtolower($category);
     $totals[$category_normalized] = isset($totals[$category_normalized]) ? $totals[$category_normalized] + $amount : $amount;
 }
 // build budget table model
 $budgetModel = new TableModel('Reciepts', 'budget');
 $budgetModel->addRow(array(TableView2::createCell('amount', 'Amount', 'th'), TableView2::createCell('store', 'Store', 'th'), TableView2::createCell('date', 'Date', 'th'), TableView2::createCell(), TableView2::createCell()));
 while (($spending_history_row = mysql_fetch_array($spending_history_data)) != null) {
     $this_id = $spending_history_row['BUDGET_ID'];
     $store = $spending_history_row['store'];
     $date = $spending_history_row['date'];
     $total = BudgetManager::getRecieptTotalById($this_id);
     $reciept_items_data = BudgetManager::getItems($this_id);
     while (($reciept_items_row = mysql_fetch_array($reciept_items_data)) != null) {
         $amount = $reciept_items_row['amount'] * $reciept_items_row['qty'] * (1 + $reciept_items_row['tax']);
         $total_spent += $amount;
         $category_normalized = strtolower($reciept_items_row['category']);
         $totals[$category_normalized] = isset($totals[$category_normalized]) ? $totals[$category_normalized] + $amount : $amount;
     }
     $budgetModel->addRow(array(TableView2::createCell('amount', format_currency($total)), TableView2::createCell('store', $spending_history_row['store']), TableView2::createCell('date', $spending_history_row['date']), TableView2::createCell('view', "<a href='receipt.php?id={$this_id}'>View</a>"), TableView2::createEdit($this_id)));
 }