fetchField(); $requirements['ec_txn_balance'] = array( 'title' => t('Transaction balance'), 'value' => $balance ? t('Transactions are not in balance!') : t('Transactions are in balance'), 'severity' => $balance ? REQUIREMENT_ERROR : REQUIREMENT_OK, 'description' => t('Checks to make sure all the transactions are internally in balance (gross - (allocated + balance) == %balance). This should be $0.00', array('%balance' => format_currency($balance))), ); if (module_exists('ec_receipt')) { $t_allocated = db_query('SELECT SUM(allocated) FROM {ec_transaction}')->fetchField(); $a_allocated = db_query("SELECT SUM(amount) FROM {ec_receipt_allocation} WHERE type = :type", array(':type' => 'transaction'))->fetchField(); $balance = $t_allocated - $a_allocated; $requirements['ec_txn_allocations'] = array( 'title' => t('Transaction allocation'), 'value' => $balance ? t('Transaction allocations are not in balance!') : t('Transactions allocations are in balance'), 'severity' => $balance ? REQUIREMENT_ERROR : REQUIREMENT_OK, 'description' => t('Checks that the allocationed amounts are equal. ie (ec_transaction.allocated - ec_receipt_allocation.amount == %balance). This should be $0.00', array('%balance' => format_currency($balance))), ); } } return $requirements; } /** * Implements hook_install(). */ function ec_store_install() { $workflow = array( array( 'workflow' => 1, 'description' => 'received', 'type' => 0, 'weight' => 1, ), array( 'workflow' => 2, 'description' => 'invoiced', 'type' => 0, 'weight' => 2, ), array( 'workflow' => 10, 'description' => 'in picking', 'type' => 0, 'weight' => 3, ), array( 'workflow' => 8, 'description' => 'packaged', 'type' => 0, 'weight' => 4, ), array( 'workflow' => 3, 'description' => 'shipped', 'type' => 0, 'weight' => 5, ), array( 'workflow' => 4, 'description' => 'awaiting customer response', 'type' => 1, 'weight' => 6, ), array( 'workflow' => 5, 'description' => 'canceled', 'type' => 2, 'weight' => 7, ), array( 'workflow' => 6, 'description' => 'completed', 'type' => 1, 'weight' => 8, ), array( 'workflow' => 7, 'description' => 'security violation', 'type' => 0, 'weight' => 9, ), ); $query = db_insert('ec_workflow_statuses')->fields(array('workflow', 'description', 'type', 'weight')); foreach ($workflow as $item) { $query->values($item); } $query->execute(); actions_save('ec_store_action_set_workflow', 'transaction', array('workflow' => '3'), 'Ship Orders'); drupal_set_message(st('e-Commerce: All core modules have been installed! You still need install at least one payment gateway in order to use the e-Commerce. Good sales!')); } /** * Implements hook_uninstall(). */ function ec_store_uninstall() { variable_del('ec_store_email_customer_invoice_subject'); variable_del('ec_store_email_customer_invoice_body'); variable_del('ec_store_email_processing_error_subject'); variable_del('ec_store_email_processing_error_body'); variable_del('ec_measure_weight'); variable_del('payment_notices'); variable_del('ec_order_overview'); variable_del('customer_invoice'); variable_del('processing_error'); variable_del('ask_customer_template'); variable_del('cancel_transaction'); variable_del('product_cart_is_destination'); variable_del('ec_goto_cart_empty'); variable_del('ec_country'); variable_del('ec_measure_weight'); variable_del('ec_measure_length'); variable_del('ec_measure_area'); variable_del('ec_measure_volume'); } /** * Implements hook_schema(). */ function ec_store_schema() { $schema = array(); $schema['ec_workflow_statuses'] = array( 'description' => 'Transaction workflow statuses table.', 'fields' => array( 'workflow' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', 'description' => 'Workflow status code.', ), 'description' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Workflow status description.', ), 'help' => array( 'type' => 'text', 'description' => 'Workflow status help text.', ), 'type' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'Workflow status type.', ), 'weight' => array( 'type' => 'int', 'not null' => TRUE, 'description' => 'Workflow status weight.', 'default' => 0, ), ), 'primary key' => array('workflow'), ); $schema['ec_fields'] = array( 'description' => 'Configuration of fields which will appear on checkout', 'fields' => array( 'name' => array( 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'description' => t('Unique identifier for each charge'), ), 'field_type' => array( 'type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => '', 'description' => 'Type of field to be created.', ), 'field_title' => array( 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', 'description' => 'Title which is shown on the checkout.', ), 'field_description' => array( 'type' => 'text', 'size' => 'medium', 'not null' => TRUE, 'description' => 'description to display on the field created.', ), 'field_error' => array( 'type' => 'text', 'size' => 'medium', 'not null' => TRUE, 'description' => 'Error message to display when the field is not used.', ), 'field_settings' => array( 'type' => 'text', 'serialize' => TRUE, ), 'weight' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => t('Weight of the charge to determine the order'), ), 'enabled' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny', 'description' => t('Set the charged as enabled.'), ), ), 'primary key' => array('name'), 'export' => array( 'key' => 'name', 'key name' => 'Name', 'can disable' => TRUE, 'status' => 'enabled', ), ); $schema['ec_transaction'] = array( 'description' => 'Transaction table.', 'fields' => array( 'txnid' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Transaction identifier.', ), 'ecid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'The {ec_customer}.ecid that owns this transaction.', ), 'type' => array( 'type' => 'varchar', 'length' => '16', 'not null' => TRUE, 'default' => '', 'description' => 'Transaction type.', ), 'mail' => array( 'type' => 'varchar', 'length' => '64', 'not null' => TRUE, 'default' => '', 'description' => 'Transaction customer email.', ), // Should I be removing this field? 'payment_method' => array( 'type' => 'varchar', 'length' => '32', 'not null' => TRUE, 'default' => '', 'description' => 'Payment method.', ), 'allocation' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'Receipt allocation status.', ), 'workflow' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Workflow status.', ), 'shippable' => array( 'type' => 'int', 'size' => 'tiny', 'default' => 0, 'not null' => FALSE, 'description' => 'Boolean indicating whether the transaction is shippable.', ), 'currency' => array( 'type' => 'varchar', 'length' => '3', 'not null' => TRUE, 'description' => 'ISO 4217 currency code.', ), 'gross' => array( 'type' => 'numeric', 'not null' => TRUE, 'default' => 0, 'precision' => '10', 'scale' => '2', 'description' => 'Transaction gross amount.', ), 'allocated' => array( 'type' => 'numeric', 'not null' => TRUE, 'default' => 0, 'precision' => '10', 'scale' => '2', 'description' => 'Total amount allocated to this transaction.', ), 'balance' => array( 'type' => 'numeric', 'not null' => TRUE, 'default' => 0, 'precision' => '10', 'scale' => '2', 'description' => 'Total amount allocated to this transaction.', ), 'created' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'The Unix timestamp when the transaction was created.', ), 'changed' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'The Unix timestamp when the transaction was most recently changed.', ), 'duedate' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'The Unix timestamp the transaction is due to.', ), 'token' => array( 'type' => 'varchar', 'length' => '42', 'not null' => TRUE, 'default' => '', 'description' => '32 bit unique transaction token.', ), 'additional' => array( 'type' => 'text', 'serialize' => TRUE, 'description' => 'Additional serialized data.', ), ), 'primary key' => array('txnid'), 'indexes' => array( 'ecid' => array('ecid'), ), ); // Note: If this table is being altered by hook_schema_alter() be sure to // change the ec_address table as well. $schema['ec_transaction_address'] = array( 'description' => 'Transaction address table.', 'fields' => array( 'txnid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The {ec_transaction}.txnid this address is belongs to.', ), 'type' => array( 'type' => 'varchar', 'length' => '16', 'not null' => TRUE, 'default' => '', 'description' => 'Address type.', ), 'fullname' => array( 'type' => 'varchar', 'length' => '32', 'not null' => TRUE, 'default' => '', 'description' => 'Full name.', ), 'firstname' => array( 'type' => 'varchar', 'length' => '32', 'not null' => TRUE, 'default' => '', 'description' => 'First name.', ), 'lastname' => array( 'type' => 'varchar', 'length' => '32', 'not null' => TRUE, 'default' => '', 'description' => 'Last name.', ), 'street1' => array( 'type' => 'varchar', 'length' => '64', 'not null' => TRUE, 'default' => '', 'description' => 'Street address line 1.', ), 'street2' => array( 'type' => 'varchar', 'length' => '64', 'not null' => TRUE, 'default' => '', 'description' => 'Street address line 2.', ), 'zip' => array( 'type' => 'varchar', 'length' => '10', 'not null' => TRUE, 'default' => '', 'description' => 'Zip/postal code.', ), 'city' => array( 'type' => 'varchar', 'length' => '32', 'not null' => TRUE, 'default' => '', 'description' => 'City.', ), 'state' => array( 'type' => 'varchar', 'length' => '32', 'not null' => TRUE, 'default' => '', 'description' => 'State/province.', ), 'country' => array( 'type' => 'varchar', 'length' => '2', 'not null' => TRUE, 'default' => '', 'description' => 'Country code.', ), ), 'primary key' => array('txnid', 'type'), ); $schema['ec_transaction_product'] = array( 'description' => 'Transaction product table.', 'fields' => array( 'txnid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The {ec_transaction}.txnid this product belongs to.', ), 'nid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The {node}.nid of this product.', ), 'vid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The {node_revisions}.vid of this product.', ), 'title' => array( 'type' => 'varchar', 'length' => '128', 'not null' => FALSE, 'description' => 'The product title/name.', ), 'price' => array( 'type' => 'numeric', 'not null' => TRUE, 'default' => 0, 'precision' => '10', 'scale' => '2', 'description' => 'The price the product was sold.', ), 'qty' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'How many products of this kind.', ), 'shippable' => array( 'type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'Boolean indicating whether the product is shippable.', ), 'data' => array( 'type' => 'text', 'not null' => FALSE, 'serialize' => TRUE, 'description' => 'Additional serialized data.', ), ), 'unique keys' => array( 'txnid' => array('txnid', 'nid'), ), 'indexes' => array( 'txnid_2' => array('txnid'), ), ); $schema['ec_transaction_misc'] = array( 'description' => 'Miscellaneous transaction table.', 'fields' => array( 'txnid' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'The {ec_transaction}.txnid this miscellaneous transaction belongs to.', ), 'type' => array( 'type' => 'varchar', 'length' => '64', 'not null' => TRUE, 'default' => '', 'description' => 'The type of this miscellaneous transaction.', ), 'vid' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'The {node_revisions}.vid of the product this miscellaneous transaction links to if any.', ), 'misc_group' => array( 'type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => '', 'description' => 'The group this miscellaneous transaction belongs to.', ), 'description' => array( 'type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', 'description' => 'Miscellaneous transaction description.', ), 'invisible' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Boolean indicating whether this miscellaneous transaction is shippable.', ), 'displayonly' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Boolean indicating whether this miscellaneous transaction is display only.', ), 'price' => array( 'type' => 'numeric', 'default' => 0, 'precision' => '10', 'scale' => '2', 'description' => 'The price/amount of this miscellaneous transaction.', ), 'qty' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1, 'description' => 'How many miscellaneous transaction of this kind.', ), 'weight' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'The weight of this miscellaneous transaction.', ), ), 'primary key' => array('txnid', 'type', 'vid'), ); $schema['ec_transaction_fields'] = array( 'fields' => array( 'txnid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Transaction identifier.', ), 'name' => array( 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'description' => t('Unique identifier for each charge'), ), 'value' => array( 'type' => 'text', 'not null' => TRUE, ), ), 'primary key' => array('txnid', 'name'), ); return $schema; } /** * Implements hook_update_last_removed(). */ function ec_store_update_last_removed() { return 6413; } /** * Add default value to ec_workflow_statuses.weight */ function ec_store_update_7400() { db_change_field('ec_workflow_statuses', 'weight', 'weight', array( 'type' => 'int', 'not null' => TRUE, 'description' => 'Workflow status weight.', 'default' => 0, )); }