| 1 |
<?php
|
| 2 |
// $Id: uc_views.views.inc,v 1.13.2.5.2.5 2009/09/29 13:40:01 madsph Exp $
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* Views 2 hooks and callback registries.
|
| 6 |
*/
|
| 7 |
|
| 8 |
define('UC_PAYER_PREFIX', "Payer's");
|
| 9 |
define('UC_RECIPIENT_PREFIX', "Recipient's");
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Implementation of hook_views_data().
|
| 13 |
*/
|
| 14 |
function uc_views_views_data() {
|
| 15 |
//Make the uc_order_products table visible for Views module
|
| 16 |
$order_products = drupal_get_schema('uc_order_products');
|
| 17 |
$data['uc_order_products']['table']['group'] = t('Order product');
|
| 18 |
$data['uc_order_products']['table']['base'] = array(
|
| 19 |
'field' => 'order_product_id',
|
| 20 |
'title' => t('Order Products'),
|
| 21 |
'help' => t('Product orders placed in your Ubercart store.'),
|
| 22 |
'weight' => -10,
|
| 23 |
);
|
| 24 |
$data['uc_order_products']['table']['join']['node'] = array(
|
| 25 |
'left_field' => 'nid',
|
| 26 |
'field' => 'nid',
|
| 27 |
);
|
| 28 |
|
| 29 |
$data['uc_order_products']['model'] = array(
|
| 30 |
'title' => t('SKU'),
|
| 31 |
'help' => $order_products['fields']['model']['description'],
|
| 32 |
'field' => array(
|
| 33 |
'handler' => 'views_handler_field',
|
| 34 |
'click sortable' => TRUE,
|
| 35 |
),
|
| 36 |
'sort' => array(
|
| 37 |
'handler' => 'views_handler_sort',
|
| 38 |
),
|
| 39 |
'filter' => array(
|
| 40 |
'handler' => 'views_handler_filter_string',
|
| 41 |
),
|
| 42 |
'argument' => array(
|
| 43 |
'handler' => 'views_handler_argument_string',
|
| 44 |
),
|
| 45 |
);
|
| 46 |
|
| 47 |
$data['uc_order_products']['qty'] = array(
|
| 48 |
'title' => t('qty'),
|
| 49 |
'help' => $order_products['fields']['qty']['description'],
|
| 50 |
'field' => array(
|
| 51 |
'handler' => 'views_handler_field',
|
| 52 |
'click sortable' => TRUE,
|
| 53 |
),
|
| 54 |
'sort' => array(
|
| 55 |
'handler' => 'views_handler_sort',
|
| 56 |
),
|
| 57 |
'filter' => array(
|
| 58 |
'handler' => 'views_handler_filter_numeric',
|
| 59 |
),
|
| 60 |
);
|
| 61 |
$data['uc_order_products']['price'] = array(
|
| 62 |
'title' => t('Price'),
|
| 63 |
'help' => $order_products['fields']['price']['description'],
|
| 64 |
'field' => array(
|
| 65 |
'handler' => 'uc_product_handler_field_price',
|
| 66 |
'click sortable' => TRUE,
|
| 67 |
),
|
| 68 |
'sort' => array(
|
| 69 |
'handler' => 'views_handler_sort',
|
| 70 |
),
|
| 71 |
'filter' => array(
|
| 72 |
'handler' => 'views_handler_filter_float',
|
| 73 |
),
|
| 74 |
);
|
| 75 |
$data['uc_order_products']['cost'] = array(
|
| 76 |
'title' => t('Cost'),
|
| 77 |
'help' => $order_products['fields']['cost']['description'],
|
| 78 |
'field' => array(
|
| 79 |
'handler' => 'uc_product_handler_field_price',
|
| 80 |
'click sortable' => TRUE,
|
| 81 |
),
|
| 82 |
'sort' => array(
|
| 83 |
'handler' => 'views_handler_sort',
|
| 84 |
),
|
| 85 |
'filter' => array(
|
| 86 |
'handler' => 'views_handler_filter_float',
|
| 87 |
),
|
| 88 |
);
|
| 89 |
$data['uc_order_products']['nid'] = array(
|
| 90 |
'title' => t('Product NID'),
|
| 91 |
'help' => t('The Node ID of the ordered product'),
|
| 92 |
'relationship' => array(
|
| 93 |
'base' => 'node',
|
| 94 |
'field' => 'nid',
|
| 95 |
'handler' => 'views_handler_relationship',
|
| 96 |
'title' => t('Product NID'),
|
| 97 |
),
|
| 98 |
);
|
| 99 |
//////////Added by jd
|
| 100 |
$data['uc_order_products']['title'] = array(
|
| 101 |
'title' => t('Product Title'),
|
| 102 |
'help' => $order_products['fields']['title']['description'],
|
| 103 |
'field' => array(
|
| 104 |
'handler' => 'views_handler_field',
|
| 105 |
'click sortable' => TRUE,
|
| 106 |
),
|
| 107 |
'sort' => array(
|
| 108 |
'handler' => 'views_handler_sort',
|
| 109 |
),
|
| 110 |
'filter' => array(
|
| 111 |
'handler' => 'views_handler_filter_string',
|
| 112 |
),
|
| 113 |
'argument' => array(
|
| 114 |
'handler' => 'views_handler_argument_string',
|
| 115 |
),
|
| 116 |
);
|
| 117 |
|
| 118 |
$data['uc_order_products']['data'] = array(
|
| 119 |
'title' => 'Product Attributes',
|
| 120 |
'help' => 'Filter by the value of a purchased products selected attributes.',
|
| 121 |
'filter' => array(
|
| 122 |
'handler' => 'views_handler_filter_in_operator',
|
| 123 |
),
|
| 124 |
);
|
| 125 |
/////////////////////
|
| 126 |
|
| 127 |
$data['uc_order_products']['ordering'] = array(
|
| 128 |
'title' => t('List position'),
|
| 129 |
'help' => t('The default sort criteria in the catalog.'),
|
| 130 |
'sort' => array(
|
| 131 |
'handler' => 'views_handler_sort',
|
| 132 |
),
|
| 133 |
);
|
| 134 |
|
| 135 |
//Make the uc_orders table visible for Views module
|
| 136 |
//Thank you river_t for original patch (order_id, order_status and uid)!
|
| 137 |
$data['uc_orders']['table']['group'] = t('Ubercart order');
|
| 138 |
|
| 139 |
// Base and use of schema for descriptions added by sammys
|
| 140 |
$order_schema = drupal_get_schema('uc_orders');
|
| 141 |
$data['uc_orders']['table']['base'] = array(
|
| 142 |
'field' => 'order_id',
|
| 143 |
'title' => t('Ubercart orders'),
|
| 144 |
'help' => t('Orders placed in your Ubercart store.'),
|
| 145 |
'weight' => -10,
|
| 146 |
);
|
| 147 |
$data['users']['table']['join']['uc_orders'] = array(
|
| 148 |
'left_field' => 'uid',
|
| 149 |
'field' => 'uid',
|
| 150 |
);
|
| 151 |
$data['users_roles']['table']['join'] = array(
|
| 152 |
'uc_orders' => array(
|
| 153 |
'left_table' => 'users',
|
| 154 |
'left_field' => 'uid',
|
| 155 |
'field' => 'uid',
|
| 156 |
),
|
| 157 |
);
|
| 158 |
$data['uc_order_products']['table']['join']['uc_orders'] = array(
|
| 159 |
'left_field' => 'order_id',
|
| 160 |
'field' => 'order_id',
|
| 161 |
);
|
| 162 |
$data['node']['table']['join']['uc_orders'] = array(
|
| 163 |
'left_table' => 'uc_order_products',
|
| 164 |
'left_field' => 'nid',
|
| 165 |
'field' => 'nid',
|
| 166 |
);
|
| 167 |
|
| 168 |
$data['term_node']['table']['join'] = array(
|
| 169 |
'uc_orders' => array(
|
| 170 |
'left_table' => 'uc_order_products',
|
| 171 |
'left_field' => 'nid',
|
| 172 |
'field' => 'nid',
|
| 173 |
),
|
| 174 |
);
|
| 175 |
|
| 176 |
$data['node']['table']['join']['uc_order_products'] = array(
|
| 177 |
'left_field' => 'nid',
|
| 178 |
'field' => 'nid',
|
| 179 |
);
|
| 180 |
$data['uc_orders']['table']['join']['node'] = array(
|
| 181 |
'left_table' => 'uc_order_products',
|
| 182 |
'left_field' => 'order_id',
|
| 183 |
'field' => 'order_id',
|
| 184 |
);
|
| 185 |
$data['uc_orders']['table']['join']['uc_order_products'] = array(
|
| 186 |
'left_field' => 'order_id',
|
| 187 |
'field' => 'order_id',
|
| 188 |
);
|
| 189 |
|
| 190 |
//sammys: optionally link to order and allow order_id as argument
|
| 191 |
$data['uc_orders']['order_id'] = array(
|
| 192 |
'title' => t('Order ID'),
|
| 193 |
'help' => $order_schema['fields']['order_id']['description'],
|
| 194 |
'field' => array(
|
| 195 |
'handler' => 'uc_views_handler_field_order_id',
|
| 196 |
'click sortable' => TRUE,
|
| 197 |
),
|
| 198 |
'sort' => array(
|
| 199 |
'handler' => 'views_handler_sort',
|
| 200 |
),
|
| 201 |
'filter' => array(
|
| 202 |
'handler' => 'views_handler_filter_numeric',
|
| 203 |
),
|
| 204 |
// sammys: Information for accepting an order id as an argument
|
| 205 |
'argument' => array(
|
| 206 |
'handler' => 'views_handler_argument_numeric',
|
| 207 |
'name field' => 'title',
|
| 208 |
'numeric' => TRUE,
|
| 209 |
'validate type' => 'order_id',
|
| 210 |
),
|
| 211 |
);
|
| 212 |
|
| 213 |
// $data['uc_orders']['distinct'] = array(
|
| 214 |
// 'title' => t('Distinct Order ID'),
|
| 215 |
// 'help' => t('Forces the query to distinctly select order id\'s, reducing duplicates.'),
|
| 216 |
// 'filter' => array(
|
| 217 |
// 'handler' => 'uc_views_handler_filter_distinct',
|
| 218 |
// ),
|
| 219 |
// );
|
| 220 |
//
|
| 221 |
$data['uc_orders']['order_status'] = array(
|
| 222 |
'title' => t('Order Status'),
|
| 223 |
'help' => $order_schema['fields']['order_status']['description'],
|
| 224 |
'field' => array(
|
| 225 |
'handler' => 'uc_views_handler_field_order_status',
|
| 226 |
'click sortable' => TRUE,
|
| 227 |
),
|
| 228 |
'sort' => array(
|
| 229 |
'handler' => 'views_handler_sort',
|
| 230 |
),
|
| 231 |
'filter' => array(
|
| 232 |
'handler' => 'views_handler_filter_order_status',
|
| 233 |
),
|
| 234 |
);
|
| 235 |
$data['uc_orders']['uid'] = array(
|
| 236 |
'title' => t('Order User ID'),
|
| 237 |
'help' => $order_schema['fields']['uid']['description'],
|
| 238 |
'field' => array(
|
| 239 |
'handler' => 'views_handler_field_user',
|
| 240 |
'click sortable' => TRUE,
|
| 241 |
),
|
| 242 |
'argument' => array(
|
| 243 |
'handler' => 'views_handler_argument_user_uid',
|
| 244 |
'name field' => 'name', // the field to display in the summary.
|
| 245 |
'numeric' => TRUE,
|
| 246 |
'validate type' => 'uid',
|
| 247 |
),
|
| 248 |
'sort' => array(
|
| 249 |
'handler' => 'views_handler_sort',
|
| 250 |
),
|
| 251 |
'filter' => array(
|
| 252 |
'handler' => 'views_handler_filter_numeric',
|
| 253 |
),
|
| 254 |
'relationship' => array(
|
| 255 |
'base' => 'users',
|
| 256 |
'field' => 'uid',
|
| 257 |
'handler' => 'views_handler_relationship',
|
| 258 |
'label' => t('Order User'),
|
| 259 |
),
|
| 260 |
);
|
| 261 |
//sammys: Changed field handler to display as a price
|
| 262 |
$data['uc_orders']['order_total'] = array(
|
| 263 |
'title' => t('Order total'),
|
| 264 |
'help' => $order_schema['fields']['order_total']['description'],
|
| 265 |
'field' => array(
|
| 266 |
'handler' => 'uc_views_handler_field_money_amount',
|
| 267 |
'click sortable' => TRUE,
|
| 268 |
),
|
| 269 |
'sort' => array(
|
| 270 |
'handler' => 'views_handler_sort',
|
| 271 |
),
|
| 272 |
'filter' => array(
|
| 273 |
'handler' => 'views_handler_filter_float',
|
| 274 |
),
|
| 275 |
);
|
| 276 |
$data['uc_orders']['payment_method'] = array(
|
| 277 |
'title' => t('Order Payment Method'),
|
| 278 |
'help' => $order_schema['fields']['payment_method']['description'],
|
| 279 |
'field' => array(
|
| 280 |
'handler' => 'views_handler_field',
|
| 281 |
'click sortable' => TRUE,
|
| 282 |
),
|
| 283 |
'sort' => array(
|
| 284 |
'handler' => 'views_handler_sort',
|
| 285 |
),
|
| 286 |
);
|
| 287 |
$data['uc_orders']['created'] = array(
|
| 288 |
'title' => t('Order Creation Date'),
|
| 289 |
'help' => $order_schema['fields']['created']['description'],
|
| 290 |
'field' => array(
|
| 291 |
'handler' => 'views_handler_field_date',
|
| 292 |
'click sortable' => TRUE,
|
| 293 |
),
|
| 294 |
'sort' => array(
|
| 295 |
'handler' => 'views_handler_sort_date',
|
| 296 |
),
|
| 297 |
'filter' => array(
|
| 298 |
'handler' => 'views_handler_filter_date',
|
| 299 |
),
|
| 300 |
);
|
| 301 |
$data['uc_orders']['product_count'] = array(
|
| 302 |
'title' => t('Order product count'),
|
| 303 |
'help' => $order_schema['fields']['product_count']['description']." (currently only available for dev versions of UC)",
|
| 304 |
'field' => array(
|
| 305 |
'handler' => 'views_handler_field_numeric',
|
| 306 |
'click sortable' => TRUE,
|
| 307 |
),
|
| 308 |
'sort' => array(
|
| 309 |
'handler' => 'views_handler_sort',
|
| 310 |
),
|
| 311 |
'filter' => array(
|
| 312 |
'handler' => 'views_handler_filter_numeric',
|
| 313 |
),
|
| 314 |
);
|
| 315 |
|
| 316 |
//Use the sleeker date_api views handler if the module is available
|
| 317 |
if(module_exists('date_api')) {
|
| 318 |
$data['uc_orders']['created']['filter']['handler'] = 'date_api_filter_handler';
|
| 319 |
}
|
| 320 |
|
| 321 |
$data['uc_orders']['modified'] = array(
|
| 322 |
'title' => t('Order Modification Date'),
|
| 323 |
'help' => $order_schema['fields']['modified']['description'],
|
| 324 |
'field' => array(
|
| 325 |
'handler' => 'views_handler_field_date',
|
| 326 |
'click sortable' => TRUE,
|
| 327 |
),
|
| 328 |
'sort' => array(
|
| 329 |
'handler' => 'views_handler_sort_date',
|
| 330 |
),
|
| 331 |
'filter' => array(
|
| 332 |
'handler' => 'views_handler_filter_date',
|
| 333 |
),
|
| 334 |
);
|
| 335 |
|
| 336 |
//Use the sleeker date_api views handler if the module is available
|
| 337 |
if(module_exists('date_api')) {
|
| 338 |
$data['uc_orders']['modified']['filter']['handler'] = 'date_api_filter_handler';
|
| 339 |
}
|
| 340 |
|
| 341 |
$data['uc_orders']['actions'] = array(
|
| 342 |
'title' => t('Order Actions'),
|
| 343 |
'help' => 'Returns the actions a user may perform on an order.',
|
| 344 |
'field' => array(
|
| 345 |
'handler' => 'uc_views_handler_field_order_actions',
|
| 346 |
'click sortable' => FALSE,
|
| 347 |
),
|
| 348 |
);
|
| 349 |
|
| 350 |
$data['uc_orders']['primary_email'] = array(
|
| 351 |
'title' => t('Email address'),
|
| 352 |
'help' => t($order_schema['fields']['primary_email']['description']),
|
| 353 |
'field' => array(
|
| 354 |
'handler' => 'views_handler_field_user_mail',
|
| 355 |
'click sortable' => TRUE,
|
| 356 |
),
|
| 357 |
'sort' => array(
|
| 358 |
'handler' => 'views_handler_sort',
|
| 359 |
),
|
| 360 |
'filter' => array(
|
| 361 |
'handler' => 'views_handler_filter_string',
|
| 362 |
),
|
| 363 |
);
|
| 364 |
|
| 365 |
$string_fields = array(
|
| 366 |
'first_name' => 'first name',
|
| 367 |
'last_name' => 'last name',
|
| 368 |
'phone' => 'phone number',
|
| 369 |
'company' => 'company',
|
| 370 |
'street1' => 'address line 1',
|
| 371 |
'street2' => 'address line 2',
|
| 372 |
'city' => 'city',
|
| 373 |
'postal_code' => 'zip/postal code',
|
| 374 |
);
|
| 375 |
|
| 376 |
foreach (array('delivery', 'billing') as $prefix) {
|
| 377 |
$args = array(
|
| 378 |
'!titleprefix' => ($prefix == 'delivery' ? UC_RECIPIENT_PREFIX : UC_PAYER_PREFIX),
|
| 379 |
);
|
| 380 |
foreach ($string_fields as $field => $suffix) {
|
| 381 |
$data['uc_orders'][$prefix.'_'.$field] = array(
|
| 382 |
'title' => t('!titleprefix !titlesuffix', $args + array('!titlesuffix' => $suffix)),
|
| 383 |
'help' => $order_schema['fields'][$prefix.'_'.$field]['description'],
|
| 384 |
'field' => array(
|
| 385 |
'handler' => 'views_handler_field',
|
| 386 |
'click sortable' => TRUE,
|
| 387 |
),
|
| 388 |
'sort' => array(
|
| 389 |
'handler' => 'views_handler_sort',
|
| 390 |
),
|
| 391 |
'filter' => array(
|
| 392 |
'handler' => 'views_handler_filter_string',
|
| 393 |
),
|
| 394 |
);
|
| 395 |
}
|
| 396 |
}
|
| 397 |
|
| 398 |
//Added by openbook
|
| 399 |
$comments_schema = drupal_get_schema('uc_order_comments');
|
| 400 |
$data['uc_order_comments']['table']['join'] = array(
|
| 401 |
'uc_orders' => array(
|
| 402 |
'left_field' => 'order_id',
|
| 403 |
'field' => 'order_id',
|
| 404 |
),
|
| 405 |
);
|
| 406 |
$data['uc_order_comments']['table']['join'] = array(
|
| 407 |
'uc_order_products' => array(
|
| 408 |
'left_field' => 'order_id',
|
| 409 |
'field' => 'order_id',
|
| 410 |
),
|
| 411 |
);
|
| 412 |
$data['uc_order_comments']['table']['group'] = t('Ubercart order comments');
|
| 413 |
$data['uc_order_comments']['message'] = array(
|
| 414 |
'title' => t('Order Comments'),
|
| 415 |
'help' => t($comments_schema['fields']['message']['description']),
|
| 416 |
'field' => array(
|
| 417 |
'handler' => 'views_handler_field',
|
| 418 |
'click sortable' => TRUE,
|
| 419 |
),
|
| 420 |
);
|
| 421 |
|
| 422 |
/**
|
| 423 |
* Countries: added by sammys
|
| 424 |
*/
|
| 425 |
|
| 426 |
$country_schema = drupal_get_schema('uc_countries');
|
| 427 |
|
| 428 |
$country_views = array(
|
| 429 |
'billing_countries' => array(
|
| 430 |
'field' => 'billing_country',
|
| 431 |
'prefix' => UC_PAYER_PREFIX,
|
| 432 |
),
|
| 433 |
'delivery_countries' => array(
|
| 434 |
'field' => 'delivery_country',
|
| 435 |
'prefix' => UC_RECIPIENT_PREFIX,
|
| 436 |
),
|
| 437 |
);
|
| 438 |
|
| 439 |
foreach ($country_views as $key => $value) {
|
| 440 |
$data['uc_orders'][$value['field']] = array(
|
| 441 |
'title' => t($value['prefix'].' country'),
|
| 442 |
'help' => t('Relate orders to '.str_replace('_', ' ', $value['field'])),
|
| 443 |
'filter' => array(
|
| 444 |
'handler' => 'uc_views_handler_filter_country',
|
| 445 |
),
|
| 446 |
'relationship' => array(
|
| 447 |
'handler' => 'views_handler_relationship',
|
| 448 |
'base' => 'uc_countries',
|
| 449 |
'relationship table' => $key,
|
| 450 |
'field' => 'country_id',
|
| 451 |
'label' => t($value['prefix'].' country'),
|
| 452 |
),
|
| 453 |
);
|
| 454 |
|
| 455 |
$data[$key]['table']['group'] = t('Ubercart order');
|
| 456 |
|
| 457 |
$data[$key]['table']['join']['uc_orders'] = array(
|
| 458 |
'table' => 'uc_countries',
|
| 459 |
'left_field' => $value['field'],
|
| 460 |
'field' => 'country_id',
|
| 461 |
);
|
| 462 |
$data[$key]['country_id'] = array(
|
| 463 |
'title' => t($value['prefix'].' country id'),
|
| 464 |
'help' => t($order_schema['fields'][$value['field']]['description']),
|
| 465 |
'field' => array(
|
| 466 |
'handler' => 'views_handler_field_numeric',
|
| 467 |
'click sortable' => TRUE,
|
| 468 |
),
|
| 469 |
// Information for accepting an order id as an argument
|
| 470 |
'argument' => array(
|
| 471 |
'handler' => 'views_handler_argument_numeric',
|
| 472 |
'name field' => 'country_iso_code_2',
|
| 473 |
'numeric' => TRUE,
|
| 474 |
'validate type' => 'country_id',
|
| 475 |
),
|
| 476 |
// Information for accepting an order id as a filter
|
| 477 |
'filter' => array(
|
| 478 |
'handler' => 'views_handler_filter_numeric',
|
| 479 |
),
|
| 480 |
// Information for sorting on an order id.
|
| 481 |
'sort' => array(
|
| 482 |
'handler' => 'views_handler_sort',
|
| 483 |
),
|
| 484 |
);
|
| 485 |
$data[$key]['country_name'] = array(
|
| 486 |
'title' => t($value['prefix'].' country name'),
|
| 487 |
'help' => t(str_replace(' ID ', ' ', $order_schema['fields'][$value['field']]['description'])),
|
| 488 |
'field' => array(
|
| 489 |
'handler' => 'views_handler_field',
|
| 490 |
'click sortable' => TRUE,
|
| 491 |
),
|
| 492 |
'sort' => array(
|
| 493 |
'handler' => 'views_handler_sort',
|
| 494 |
),
|
| 495 |
'filter' => array(
|
| 496 |
'handler' => 'views_handler_filter_string',
|
| 497 |
),
|
| 498 |
);
|
| 499 |
$data[$key]['country_iso_code_2'] = array(
|
| 500 |
'title' => t($value['prefix'].' country ISO code (2 characters)'),
|
| 501 |
'help' => t($country_schema['fields']['country_iso_code_2']['description']),
|
| 502 |
'field' => array(
|
| 503 |
'handler' => 'views_handler_field',
|
| 504 |
'click sortable' => TRUE,
|
| 505 |
),
|
| 506 |
'sort' => array(
|
| 507 |
'handler' => 'views_handler_sort',
|
| 508 |
),
|
| 509 |
'filter' => array(
|
| 510 |
'handler' => 'views_handler_filter_string',
|
| 511 |
),
|
| 512 |
);
|
| 513 |
$data[$key]['country_iso_code_3'] = array(
|
| 514 |
'title' => t($value['prefix'].' country ISO code (3 characters)'),
|
| 515 |
'help' => t($country_schema['fields']['country_iso_code_3']['description']),
|
| 516 |
'field' => array(
|
| 517 |
'handler' => 'views_handler_field',
|
| 518 |
'click sortable' => TRUE,
|
| 519 |
),
|
| 520 |
'sort' => array(
|
| 521 |
'handler' => 'views_handler_sort',
|
| 522 |
),
|
| 523 |
'filter' => array(
|
| 524 |
'handler' => 'views_handler_filter_string',
|
| 525 |
),
|
| 526 |
);
|
| 527 |
}
|
| 528 |
|
| 529 |
/**
|
| 530 |
* Zones: added by sammys
|
| 531 |
*/
|
| 532 |
$zone_schema = drupal_get_schema('uc_zones');
|
| 533 |
|
| 534 |
$zone_views = array(
|
| 535 |
'billing_zones' => array(
|
| 536 |
'field' => 'billing_zone',
|
| 537 |
'prefix' => UC_PAYER_PREFIX,
|
| 538 |
),
|
| 539 |
'delivery_zones' => array(
|
| 540 |
'field' => 'delivery_zone',
|
| 541 |
'prefix' => UC_RECIPIENT_PREFIX,
|
| 542 |
),
|
| 543 |
);
|
| 544 |
|
| 545 |
foreach ($zone_views as $key => $value) {
|
| 546 |
$data['uc_orders'][$value['field']] = array(
|
| 547 |
'title' => t($value['prefix'].' zone'),
|
| 548 |
'help' => t('Relate orders to '.str_replace('_', ' ', $value['field'])),
|
| 549 |
'filter' => array(
|
| 550 |
'handler' => 'uc_views_handler_filter_zone',
|
| 551 |
),
|
| 552 |
'relationship' => array(
|
| 553 |
'handler' => 'views_handler_relationship',
|
| 554 |
'base' => 'uc_zones',
|
| 555 |
'relationship table' => $key,
|
| 556 |
'field' => 'zone_id',
|
| 557 |
'label' => t($value['prefix'].' zone'),
|
| 558 |
),
|
| 559 |
);
|
| 560 |
|
| 561 |
$data[$key]['table']['group'] = t('Ubercart order');
|
| 562 |
|
| 563 |
$data[$key]['table']['join']['uc_orders'] = array(
|
| 564 |
'table' => 'uc_zones',
|
| 565 |
'left_field' => $value['field'],
|
| 566 |
'field' => 'zone_id',
|
| 567 |
);
|
| 568 |
$data[$key]['zone_id'] = array(
|
| 569 |
'title' => t($value['prefix'].' zone id'),
|
| 570 |
'help' => t($order_schema['fields'][$value['field']]['description']),
|
| 571 |
'field' => array(
|
| 572 |
'handler' => 'views_handler_field_numeric',
|
| 573 |
'click sortable' => TRUE,
|
| 574 |
),
|
| 575 |
// Information for accepting an order id as an argument
|
| 576 |
'argument' => array(
|
| 577 |
'handler' => 'views_handler_argument_numeric',
|
| 578 |
'name field' => 'zone_code',
|
| 579 |
'numeric' => TRUE,
|
| 580 |
'validate type' => 'zone_id',
|
| 581 |
),
|
| 582 |
// Information for accepting an order id as a filter
|
| 583 |
'filter' => array(
|
| 584 |
'handler' => 'views_handler_filter_numeric',
|
| 585 |
),
|
| 586 |
// Information for sorting on an order id.
|
| 587 |
'sort' => array(
|
| 588 |
'handler' => 'views_handler_sort',
|
| 589 |
),
|
| 590 |
);
|
| 591 |
$data[$key]['zone_name'] = array(
|
| 592 |
'title' => t($value['prefix'].' zone name'),
|
| 593 |
'help' => t(ereg_replace(' (id|ID) ', ' ', $order_schema['fields'][$value['field']]['description'])),
|
| 594 |
'field' => array(
|
| 595 |
'handler' => 'views_handler_field',
|
| 596 |
'click sortable' => TRUE,
|
| 597 |
),
|
| 598 |
'sort' => array(
|
| 599 |
'handler' => 'views_handler_sort',
|
| 600 |
),
|
| 601 |
'filter' => array(
|
| 602 |
'handler' => 'views_handler_filter_string',
|
| 603 |
),
|
| 604 |
);
|
| 605 |
|
| 606 |
$data[$key]['zone_code'] = array(
|
| 607 |
'title' => t($value['prefix'].' zone code'),
|
| 608 |
'help' => t(str_replace('of the ', 'of the '.strtolower($value['prefix']).' ', $zone_schema['fields']['zone_code']['description'])),
|
| 609 |
'field' => array(
|
| 610 |
'handler' => 'views_handler_field',
|
| 611 |
'click sortable' => TRUE,
|
| 612 |
),
|
| 613 |
'sort' => array(
|
| 614 |
'handler' => 'views_handler_sort',
|
| 615 |
),
|
| 616 |
'filter' => array(
|
| 617 |
'handler' => 'views_handler_filter_string',
|
| 618 |
),
|
| 619 |
);
|
| 620 |
}
|
| 621 |
|
| 622 |
/**
|
| 623 |
* Shipping and Tax Line Items added by dandaman for August Ash Inc.
|
| 624 |
*/
|
| 625 |
$data['uc_order_line_items_shipping']['table']['join']['uc_orders'] = array(
|
| 626 |
'table' => 'uc_order_line_items',
|
| 627 |
'left_field' => 'order_id',
|
| 628 |
'field' => 'order_id',
|
| 629 |
'extra' => array(
|
| 630 |
array(
|
| 631 |
'field' => 'type',
|
| 632 |
'value' => 'shipping',
|
| 633 |
),
|
| 634 |
),
|
| 635 |
);
|
| 636 |
$data['uc_order_line_items_shipping']['table']['group'] = t('Ubercart order');
|
| 637 |
$data['uc_order_line_items_shipping']['title'] = array(
|
| 638 |
'title' => t('Shipping Quote Title'),
|
| 639 |
'help' => t('The shipping method or note.'),
|
| 640 |
'field' => array(
|
| 641 |
'handler' => 'views_handler_field',
|
| 642 |
'click sortable' => TRUE,
|
| 643 |
),
|
| 644 |
);
|
| 645 |
$data['uc_order_line_items_shipping']['amount'] = array(
|
| 646 |
'title' => t('Shipping Quote Amount'),
|
| 647 |
'help' => t('The shipping amount.'),
|
| 648 |
'field' => array(
|
| 649 |
'handler' => 'uc_product_handler_field_price',
|
| 650 |
'click sortable' => TRUE,
|
| 651 |
),
|
| 652 |
);
|
| 653 |
|
| 654 |
$data['uc_order_line_items_tax']['table']['join']['uc_orders'] = array(
|
| 655 |
'table' => 'uc_order_line_items',
|
| 656 |
'left_field' => 'order_id',
|
| 657 |
'field' => 'order_id',
|
| 658 |
'extra' => array(
|
| 659 |
array(
|
| 660 |
'field' => 'type',
|
| 661 |
'value' => 'tax',
|
| 662 |
),
|
| 663 |
),
|
| 664 |
);
|
| 665 |
$data['uc_order_line_items_tax']['table']['group'] = t('Ubercart order');
|
| 666 |
$data['uc_order_line_items_tax']['title'] = array(
|
| 667 |
'title' => t('Tax Title'),
|
| 668 |
'help' => t('The tax title or note, if there is one.'),
|
| 669 |
'field' => array(
|
| 670 |
'handler' => 'views_handler_field',
|
| 671 |
'click sortable' => TRUE,
|
| 672 |
),
|
| 673 |
);
|
| 674 |
$data['uc_order_line_items_tax']['amount'] = array(
|
| 675 |
'title' => t('Tax Amount'),
|
| 676 |
'help' => t('The tax amount.'),
|
| 677 |
'field' => array(
|
| 678 |
'handler' => 'uc_product_handler_field_price',
|
| 679 |
'click sortable' => TRUE,
|
| 680 |
),
|
| 681 |
);
|
| 682 |
|
| 683 |
//Make the uc_cart_products table visible for Views module
|
| 684 |
$data['uc_cart_products']['table']['group'] = t('Cart product');
|
| 685 |
$data['uc_cart_products']['table']['join']['node'] = array(
|
| 686 |
'left_field' => 'nid',
|
| 687 |
'field' => 'nid',
|
| 688 |
);
|
| 689 |
$data['uc_cart_products']['table']['join']['users'] = array(
|
| 690 |
'left_field' => 'uid',
|
| 691 |
'field' => 'cart_id',
|
| 692 |
);
|
| 693 |
$data['uc_cart_products']['nid'] = array(
|
| 694 |
'title' => t('Cart product id'),
|
| 695 |
'help' => t('The nid of the product for in a cart.'),
|
| 696 |
'field' => array(
|
| 697 |
'handler' => 'views_handler_field_node',
|
| 698 |
'click sortable' => TRUE,
|
| 699 |
),
|
| 700 |
'argument' => array(
|
| 701 |
'handler' => 'views_handler_argument_node_nid',
|
| 702 |
'name field' => 'title', // the field to display in the summary.
|
| 703 |
'numeric' => TRUE,
|
| 704 |
'validate type' => 'nid',
|
| 705 |
),
|
| 706 |
'sort' => array(
|
| 707 |
'handler' => 'views_handler_sort',
|
| 708 |
),
|
| 709 |
'filter' => array(
|
| 710 |
'handler' => 'views_handler_filter_numeric',
|
| 711 |
),
|
| 712 |
);
|
| 713 |
$data['uc_cart_products']['cart_id'] = array(
|
| 714 |
'title' => t('Cart id'),
|
| 715 |
'help' => t('The id of the cart (either user or session id).'),
|
| 716 |
'field' => array(
|
| 717 |
'handler' => 'uc_views_handler_field_cart_user',
|
| 718 |
'click sortable' => TRUE,
|
| 719 |
),
|
| 720 |
'argument' => array(
|
| 721 |
'handler' => 'views_handler_argument_user_uid',
|
| 722 |
'name field' => 'name', // the field to display in the summary.
|
| 723 |
'numeric' => TRUE,
|
| 724 |
'validate type' => 'cart_id',
|
| 725 |
),
|
| 726 |
'sort' => array(
|
| 727 |
'handler' => 'views_handler_sort',
|
| 728 |
),
|
| 729 |
'filter' => array(
|
| 730 |
'handler' => 'views_handler_filter_numeric',
|
| 731 |
),
|
| 732 |
);
|
| 733 |
$data['uc_cart_products']['qty'] = array(
|
| 734 |
'title' => t('qty'),
|
| 735 |
'help' => t('The amount ordered.'),
|
| 736 |
'field' => array(
|
| 737 |
'handler' => 'views_handler_field_numeric',
|
| 738 |
'click sortable' => TRUE,
|
| 739 |
),
|
| 740 |
'sort' => array(
|
| 741 |
'handler' => 'views_handler_sort',
|
| 742 |
),
|
| 743 |
'filter' => array(
|
| 744 |
'handler' => 'views_handler_filter_numeric',
|
| 745 |
),
|
| 746 |
);
|
| 747 |
$data['uc_cart_products']['changed'] = array(
|
| 748 |
'title' => t('Cart Product Line Changed Date'),
|
| 749 |
'help' => t('The date the cart line was changed'),
|
| 750 |
'field' => array(
|
| 751 |
'handler' => 'views_handler_field_date',
|
| 752 |
'click sortable' => TRUE,
|
| 753 |
),
|
| 754 |
'sort' => array(
|
| 755 |
'handler' => 'views_handler_sort_date',
|
| 756 |
),
|
| 757 |
'filter' => array(
|
| 758 |
'handler' => 'views_handler_filter_date',
|
| 759 |
),
|
| 760 |
);
|
| 761 |
|
| 762 |
$data['uc_cart_products']['ordering'] = array(
|
| 763 |
'title' => t('List position'),
|
| 764 |
'help' => t('The default sort criteria in the catalog.'),
|
| 765 |
'sort' => array(
|
| 766 |
'handler' => 'views_handler_sort',
|
| 767 |
),
|
| 768 |
);
|
| 769 |
|
| 770 |
//Extra handlers for uc_products
|
| 771 |
$data['uc_products']['conditionalbuyitnowbutton'] = array(
|
| 772 |
'title' => t('Conditional buy it now button'),
|
| 773 |
'help' => t('A button to add a product to the cart without quantity or attribute fields, if certain conditions are met.'),
|
| 774 |
'group' => t('Product'),
|
| 775 |
'field' => array(
|
| 776 |
'table' => 'node',
|
| 777 |
'additional fields' => array(
|
| 778 |
'nid' => array(
|
| 779 |
'table' => 'node',
|
| 780 |
'field' => 'nid',
|
| 781 |
), ),
|
| 782 |
'handler' => 'uc_views_handler_field_conditional_buyitnow',
|
| 783 |
),
|
| 784 |
);
|
| 785 |
$data['uc_products']['conditionaladdtocart'] = array(
|
| 786 |
'title' => t('Conditional add to cart form'),
|
| 787 |
'help' => t("Form to put the product in the customer's cart, if certain conditions are met."),
|
| 788 |
'group' => t('Product'),
|
| 789 |
'field' => array(
|
| 790 |
'additional fields' => array(
|
| 791 |
'nid' => array(
|
| 792 |
'table' => 'node',
|
| 793 |
'field' => 'nid',
|
| 794 |
),
|
| 795 |
'type' => array(
|
| 796 |
'table' => 'node',
|
| 797 |
'field' => 'type',
|
| 798 |
),
|
| 799 |
),
|
| 800 |
'handler' => 'uc_views_handler_field_conditional_addtocart',
|
| 801 |
),
|
| 802 |
);
|
| 803 |
//Thank you hanoii for this addition
|
| 804 |
$data['uc_products']['ordering'] = array(
|
| 805 |
'field' => array(
|
| 806 |
'help' => t("The product list position."),
|
| 807 |
'handler' => 'views_handler_field_numeric',
|
| 808 |
),
|
| 809 |
);
|
| 810 |
|
| 811 |
|
| 812 |
return $data;
|
| 813 |
}
|
| 814 |
|
| 815 |
/**
|
| 816 |
* Implementation of hook_views_handlers().
|
| 817 |
*/
|
| 818 |
function uc_views_views_handlers() {
|
| 819 |
return array(
|
| 820 |
'info' => array(
|
| 821 |
'path' => drupal_get_path('module', 'uc_views') . '/views',
|
| 822 |
),
|
| 823 |
'handlers' => array(
|
| 824 |
// fields
|
| 825 |
'uc_views_handler_field_order_id' => array( 'parent' => 'views_handler_field',),
|
| 826 |
'uc_views_handler_field_cart_user' => array('parent' => 'views_handler_field',),
|
| 827 |
'uc_views_handler_field_order_actions' => array( 'parent' => 'views_handler_field',),
|
| 828 |
'uc_views_handler_field_country' => array( 'parent' => 'views_handler_field',),
|
| 829 |
'uc_views_handler_field_zone' => array( 'parent' => 'views_handler_field',),
|
| 830 |
'uc_views_handler_field_order_status' => array( 'parent' => 'views_handler_field',),
|
| 831 |
'uc_views_handler_field_conditional_buyitnow' => array('parent' => 'views_handler_field',),
|
| 832 |
'uc_views_handler_field_conditional_addtocart' => array('parent' => 'views_handler_field',),
|
| 833 |
'uc_views_handler_field_money_amount' => array('parent' => 'views_handler_field',),
|
| 834 |
//fiters
|
| 835 |
'views_handler_filter_order_status' => array('parent' => 'views_handler_filter_in_operator',),
|
| 836 |
'uc_views_handler_filter_country' => array('parent' => 'views_handler_filter_in_operator',),
|
| 837 |
'uc_views_handler_filter_zone' => array('parent' => 'views_handler_filter_in_operator',),
|
| 838 |
// 'uc_views_handler_filter_distinct' => array('parent' => 'views_handler_filter',),
|
| 839 |
),
|
| 840 |
);
|
| 841 |
}
|
| 842 |
|
| 843 |
/**
|
| 844 |
* Conditionally add editablefields support.
|
| 845 |
*/
|
| 846 |
function uc_views_views_tables_alter(&$tables) {
|
| 847 |
}
|
| 848 |
|
| 849 |
function uc_views_views_plugins() {
|
| 850 |
return array(
|
| 851 |
'module' => 'uc_views', // This just tells our themes are elsewhere.
|
| 852 |
'row' => array(
|
| 853 |
'uc_views_invoice' => array(
|
| 854 |
'title' => t('Invoice'),
|
| 855 |
'help' => t('Display the order with standard invoice view.'),
|
| 856 |
'handler' => 'uc_views_plugin_row_invoice_view',
|
| 857 |
'path' => drupal_get_path('module', 'uc_views') . '/views',
|
| 858 |
'theme' => 'uc_views_view_row_invoice',
|
| 859 |
'theme path' => drupal_get_path('module', 'uc_views') . '/theme',
|
| 860 |
'theme file' => 'theme.inc',
|
| 861 |
'base' => array('uc_orders'), // only works with 'uc_orders' as base.
|
| 862 |
//'uses options' => TRUE,
|
| 863 |
'type' => 'normal',
|
| 864 |
),
|
| 865 |
),
|
| 866 |
);
|
| 867 |
}
|