コード例 #1
0
        
        $position++;
        $location           = $campaign->field_dw_campaign_location[0]['value']; // $campaign->title;
        list($distance,)    = split('-', $id);
        $walkers            = count(get_object_vars($pcps));
        $amount             = dw_campaigns_get_contribution_total_for_campaign($campaign);
        $campaign_id        = $campaign->nid;
        
        db_query("insert into {distance_as_$num_per_page} (position, location, distance, walkers, amount, campaign_id) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", $position, $location, $distance, $walkers, $amount, $campaign_id);

    }


    $sql_count = "select count(*) from distance_as_$num_per_page";

    $result = pager_query("select * from distance_as_$num_per_page " . tablesort_sql($headers), $num_per_page, 0, $sql_count);

    $rows = array();
    while ($db_row = db_fetch_object($result)) {
        $our_campaign = node_load($db_row->campaign_id);

        $rows[] = array(
            'data' => array(
                array('data' => $db_row->position, 'class' => 'position'),
                array('data' => '<a href="/dw/walking/location/' . $db_row->campaign_id . '">' . $db_row->location . '</a>', 'class' => 'location'),
                array('data' => floor($db_row->distance) . ' ' . $units_wd, 'class' => 'distance'),
                array('data' => $db_row->walkers,  'class' => 'walkers'),
                array('data' => dw_campaigns_force_decimal($db_row->amount, $campaign->field_dw_currency['0']['value'])),
            )    
        );
    }
コード例 #2
0
 public static function _sort()
 {
     $args = func_get_args();
     // making things more readable
     $fields = $args[0];
     $table = $args[1];
     $where = $args[2];
     $action = $args[3];
     $header = array();
     $where_clause = '';
     # build the header
     foreach ($fields as $title => $field) {
         $header[] = array('data' => t($title), 'field' => $field);
     }
     # action column :)
     if (isset($action)) {
         $header[] = t($action);
     }
     // @drupal API (v6)
     $sort = tablesort_sql($header);
     $field_list = implode(',', $fields);
     # build the where clause
     if (!isset($where)) {
         $where_clause = '';
     } else {
         if (count($where) == 1) {
             $key = key($where);
             $where_clause = sprintf("WHERE %s = '%s'", $key, $where[$key]);
         } else {
             $i = 0;
             $where_clause = 'WHERE ';
             foreach ($where as $field => $value) {
                 if ($i == 0) {
                     $where_clause .= sprintf("%s = '%s'", $field, $value);
                 } else {
                     $where_clause .= sprintf(" AND %s = '%s'", $field, $value);
                 }
                 $i++;
             }
         }
     }
     # we can really just return $query
     $query = sprintf("SELECT %s FROM {%s} %s %s", $field_list, $table, $where_clause, $sort);
     return array('header' => $header, 'query' => $query);
     // @drupal API (v6)
     // return pager_query($query, 50, 0, null);
 }
コード例 #3
0
        $photo      = _dw_campaigns_get_photo(array(), array(), 'donation-photo', $supporter->id, $image_match);
        $email      = $contact->email;
        $amount     = $supporter->amount;
        $location   = $contact->city . ', ' . $contact->state_province;
        //$date       = substr($contribution->receive_date, 0, 10);
        $date       = $contribution->receive_date;
        $note       = is_object($supporter->pcp_personal_note)?'':$supporter->pcp_personal_note;
        $pay_later  = $supporter->is_pay_later;
        
        db_query("insert into {donations_as} (name, photo, email, amount, location, donationdate, note, is_pay_later) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $name, $photo, $email, $amount, $location, $date, $note, $pay_later);
    }

    $sql_count = "select count(*) from donations_as";

    //$result = db_query("select * from donations_as " . tablesort_sql($headers));
    $result = pager_query("select * from donations_as " . tablesort_sql($headers), $num_per_page, 0, $sql_count);

    $rows = array();
    while ($db_row = db_fetch_object($result)) {
        $tr_class = ($db_row->is_pay_later == 1) ? 'is_pay_later' : '';

        $rows[] = array(
            'data' => array(
                array('data' => '<img src="' . $db_row->photo . '" width="25"> <a href="mailto:' . $db_row->email . '">' . $db_row->name . '</a>', 'class' => 'name' ),
                array('data' => dw_campaigns_force_decimal($db_row->amount, $campaign->field_dw_currency['0']['value']), 'class' => 'amount'),
                array('data' => $db_row->location, 'class' => 'location'),
                array('data' => dw_campaigns_format_date($db_row->donationdate), 'class' => 'date'),
                array('data' => $db_row->note, 'class' => 'note'),
            ),
            'class' => $tr_class
        );
コード例 #4
0
ファイル: DbPeople.class.php プロジェクト: chgk/db.chgk.info
 private function getTableHtml()
 {
     global $pager_total_items;
     $filter = $this->build_filter_query();
     $header = array(array('data' => '&#8470;'), array('data' => 'Фамилия, имя', 'field' => 'p.surname'), array('data' => 'Турниров', 'field' => 'p.TNumber', 'sort' => 'desc'), array('data' => 'Вопросов', 'field' => 'p.QNumber'), array('data' => 'Сертификация', 'field' => 'p.QNumber'), array('data' => 'Ник на сайте'));
     $sql = "SELECT  p.* from {People} p {$filter['join']} WHERE 1 {$filter['where']} GROUP BY CharId";
     $sql .= tablesort_sql($header);
     $sql = preg_replace('/(p\\.surname\\s+(A|DE)SC)/', '$1, p.name $2SC', $sql);
     $query_count = "SELECT count(DISTINCT CharId) from  {People} p {$filter['join']} WHERE 1 {$filter['where']}";
     $result = pager_query($sql, 50, 0, $query_count, $filter['args']);
     $rows = array();
     $output .= '<p>' . $pager_total_items[0] . ' человек' . $this->suffix($pager_total_items[0]) . '</p>';
     $n = isset($_GET['page']) ? $_GET['page'] * 50 : 0;
     while ($line = db_fetch_object($result)) {
         $n++;
         $person = DbPerson::newFromRow($line);
         $cert = array();
         if ($person->isCertifiedEditor()) {
             $cert[] = 'редактор';
         }
         if ($person->isCertifiedReferee()) {
             $cert[] = 'арбитр';
         }
         $cert = $cert ? implode(', ', $cert) : '&mdash;';
         $nick = $person->getNick() or $nick = '&mdash;';
         $rows[] = array($n, $person->getLink(), $person->getToursNumber(), $person->getQuestionsNumber(), $cert, $nick);
     }
     $output .= theme('table', $header, $rows);
     $output .= theme('pager', NULL, 50, 0);
     return $output;
     /*    $accounts[$account->uid] = '';
         $form['name'][$account->uid] = array('#value' => theme('username', $account));
         $form['status'][$account->uid] =  array('#value' => $status[$account->status]);
         $users_roles = array();
         $roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = %d', $account->uid);
         while ($user_role = db_fetch_object($roles_result)) {
           $users_roles[] = $roles[$user_role->rid];
         }
         asort($users_roles);
         $form['roles'][$account->uid][0] = array('#value' => theme('item_list', $users_roles));
         $form['member_for'][$account->uid] = array('#value' => format_interval(time() - $account->created));
         $form['last_access'][$account->uid] =  array('#value' => $account->access ? t('@time ago', array('@time' => format_interval(time() - $account->access))) : t('never'));
         $form['operations'][$account->uid] = array('#value' => l(t('edit'), "user/$account->uid/edit", array('query' => $destination)));
       }*/
 }