<?php
/* Open report modules.*/
$config->report = new stdclass();
$config->report->moduleList['customer']         = TABLE_CUSTOMER;
$config->report->moduleList['order']            = TABLE_ORDER;
$config->report->moduleList['contract']         = TABLE_CONTRACT;
$config->report->moduleList['purchasecontract'] = TABLE_CONTRACT;
$config->report->moduleList['trade']            = TABLE_TRADE;
$config->report->moduleList['product']          = TABLE_PRODUCT;

$config->report->customer = new stdclass();
/* select conditions, groupBy|(count field default is same as groupby)|(count|sum default is count). */
$config->report->customer->chartList['assignedTo'] = 'assignedTo||';
$config->report->customer->chartList['status']     = 'status||';
$config->report->customer->chartList['level']      = 'level||';
$config->report->customer->chartList['type']       = 'type||';
$config->report->customer->chartList['size']       = 'size||';
$config->report->customer->chartList['area']       = 'area||';
$config->report->customer->chartList['industry']   = 'industry||';

/* type list name. */
$config->report->customer->listName['assignedTo'] = 'USERS';
$config->report->customer->listName['status']     = 'statusList';
$config->report->customer->listName['level']      = 'levelNameList';
$config->report->customer->listName['type']       = 'typeList';
$config->report->customer->listName['size']       = 'sizeNameList';
$config->report->customer->listName['area']       = 'AREA';
$config->report->customer->listName['industry']   = 'INDUSTRY';

/* order setting. */
$config->report->order = new stdclass();
$config->report->order->chartList['product']      = 'product_multi||';
$config->report->order->chartList['productLine']  = 'productLine_multi||';
$config->report->order->chartList['status']       = 'status||';
$config->report->order->chartList['createdBy']    = 'createdBy||';
$config->report->order->chartList['assignedTo']   = 'assignedTo||';
$config->report->order->chartList['year']         = 'year|id|';
$config->report->order->chartList['month']        = 'month|id|';
$config->report->order->chartList['productA']     = 'product_multi|`real`|sum';
$config->report->order->chartList['productLineA'] = 'productLine_multi|`real`|sum';
$config->report->order->chartList['statusA']      = 'status|`real`|sum';
$config->report->order->chartList['createdByA']   = 'createdBy|`real`|sum';
$config->report->order->chartList['assignedToA']  = 'assignedTo|`real`|sum';
$config->report->order->chartList['yearA']        = 'year|`real`|sum';
$config->report->order->chartList['monthA']       = 'month|`real`|sum';

$config->report->order->listName['product']      = 'PRODUCTS';
$config->report->order->listName['productLine']  = 'productLineList';
$config->report->order->listName['status']       = 'statusList';
$config->report->order->listName['createdBy']    = 'USERS';
$config->report->order->listName['assignedTo']   = 'USERS';
$config->report->order->listName['productA']     = 'PRODUCTS';
$config->report->order->listName['productLineA'] = 'productLineList';
$config->report->order->listName['statusA']      = 'statusList';
$config->report->order->listName['createdByA']   = 'USERS';
$config->report->order->listName['assignedToA']  = 'USERS';

/* contract setting. */
$config->report->contract = new stdclass();
$config->report->contract->chartList['customer']     = 'customer||';
$config->report->contract->chartList['status']       = 'status||';
$config->report->contract->chartList['delivery']     = 'delivery||';
$config->report->contract->chartList['return']       = '`return`||';
$config->report->contract->chartList['createdBy']    = 'createdBy||';
$config->report->contract->chartList['signedBy']     = 'signedBy||';
$config->report->contract->chartList['deliveredBy']  = 'deliveredBy||';
$config->report->contract->chartList['contactedBy']  = 'contact||';
$config->report->contract->chartList['year']         = 'year|id|';
$config->report->contract->chartList['month']        = 'month|id|';
$config->report->contract->chartList['customerA']    = 'customer|amount|sum';
$config->report->contract->chartList['statusA']      = 'status|amount|sum';
$config->report->contract->chartList['deliveryA']    = 'delivery|amount|sum';
$config->report->contract->chartList['returnA']      = '`return`|amount|sum';
$config->report->contract->chartList['createdByA']   = 'createdBy|amount|sum';
$config->report->contract->chartList['signedByA']    = 'signedBy|amount|sum';
$config->report->contract->chartList['deliveredByA'] = 'deliveredBy|amount|sum';
$config->report->contract->chartList['contactedByA'] = 'contact|amount|sum';
$config->report->contract->chartList['yearA']        = 'year|amount|sum';
$config->report->contract->chartList['monthA']       = 'month|amount|sum';

$config->report->contract->listName['customer']     = 'CUSTOMERS';
$config->report->contract->listName['status']       = 'statusList';
$config->report->contract->listName['delivery']     = 'deliveryList';
$config->report->contract->listName['return']       = 'returnList';
$config->report->contract->listName['createdBy']    = 'USERS';
$config->report->contract->listName['signedBy']     = 'USERS';
$config->report->contract->listName['deliveredBy']  = 'USERS';
$config->report->contract->listName['contactedBy']  = 'CONTACT';
$config->report->contract->listName['customerA']    = 'CUSTOMERS';
$config->report->contract->listName['statusA']      = 'statusList';
$config->report->contract->listName['deliveryA']    = 'deliveryList';
$config->report->contract->listName['returnA']      = 'returnList';
$config->report->contract->listName['createdByA']   = 'USERS';
$config->report->contract->listName['signedByA']    = 'USERS';
$config->report->contract->listName['deliveredByA'] = 'USERS';
$config->report->contract->listName['contactedByA'] = 'CONTACT';

/* purchasecontract setting. */
$config->report->purchasecontract = new stdclass();
$config->report->purchasecontract->chartList['customer']     = 'customer||';
$config->report->purchasecontract->chartList['status']       = 'status||';
$config->report->purchasecontract->chartList['return']       = '`return`||';
$config->report->purchasecontract->chartList['createdBy']    = 'createdBy||';
$config->report->purchasecontract->chartList['signedBy']     = 'signedBy||';
$config->report->purchasecontract->chartList['contactedBy']  = 'contact||';
$config->report->purchasecontract->chartList['year']         = 'year|id|';
$config->report->purchasecontract->chartList['month']        = 'month|id|';
$config->report->purchasecontract->chartList['customerA']    = 'customer|amount|sum';
$config->report->purchasecontract->chartList['statusA']      = 'status|amount|sum';
$config->report->purchasecontract->chartList['returnA']      = '`return`|amount|sum';
$config->report->purchasecontract->chartList['createdByA']   = 'createdBy|amount|sum';
$config->report->purchasecontract->chartList['signedByA']    = 'signedBy|amount|sum';
$config->report->purchasecontract->chartList['contactedByA'] = 'contact|amount|sum';
$config->report->purchasecontract->chartList['yearA']        = 'year|amount|sum';
$config->report->purchasecontract->chartList['monthA']       = 'month|amount|sum';

$config->report->purchasecontract->listName['customer']     = 'CUSTOMERS';
$config->report->purchasecontract->listName['status']       = 'statusList';
$config->report->purchasecontract->listName['return']       = 'returnList';
$config->report->purchasecontract->listName['createdBy']    = 'USERS';
$config->report->purchasecontract->listName['signedBy']     = 'USERS';
$config->report->purchasecontract->listName['contactedBy']  = 'CONTACT';
$config->report->purchasecontract->listName['customerA']    = 'CUSTOMERS';
$config->report->purchasecontract->listName['statusA']      = 'statusList';
$config->report->purchasecontract->listName['returnA']      = 'returnList';
$config->report->purchasecontract->listName['createdByA']   = 'USERS';
$config->report->purchasecontract->listName['signedByA']    = 'USERS';
$config->report->purchasecontract->listName['contactedByA'] = 'CONTACT';

/* Open daily reminder.*/
$config->report->dailyreminder           = new stdclass();
$config->report->dailyreminder->todo     = true;
$config->report->dailyreminder->task     = true;
$config->report->dailyreminder->order    = true;
$config->report->dailyreminder->contract = true;
$config->report->dailyreminder->customer = true;

$config->report->queryConditions['order']    = 'o.id';
$config->report->queryConditions['contract'] = 't1.id';
$config->report->queryConditions['customer'] = 't1.id';

/* Build module menu if exist this module. */
$config->report->moduleMenu['contract']         = 'crm|contract|sale';
$config->report->moduleMenu['purchasecontract'] = 'crm|contract|purchase';
