Rajout du module de gestion des avoirs

This commit is contained in:
2020-06-10 10:26:45 +02:00
parent d3e8302015
commit 4e01079f72
115 changed files with 52849 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
#2.3.0
- First public version, OpenSource <3

View File

@@ -0,0 +1,10 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
ALTER TABLE `credit_note` ADD `discount_without_tax` DECIMAL(16,6) DEFAULT 0.000000 AFTER `total_price_with_tax`, ADD `discount_with_tax` DECIMAL(16,6) DEFAULT 0.000000 AFTER `discount_without_tax`;
ALTER TABLE `credit_note_version` ADD `discount_without_tax` DECIMAL(16,6) DEFAULT 0.000000 AFTER `total_price_with_tax`, ADD `discount_with_tax` DECIMAL(16,6) DEFAULT 0.000000 AFTER `discount_without_tax`;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,16 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
SELECT @max_id := IFNULL(MAX(`id`),0) FROM `credit_note_type`;
INSERT INTO `credit_note_type` (`id`, `code`, `position`, `color`, `required_order`, `created_at`, `updated_at`) VALUES
(@max_id+1, 'difference_refund', @max_id+1, '#CF7973', 0, NOW(), NOW());
INSERT INTO `credit_note_type_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES
(@max_id+1, 'en_US', 'Difference refund', '', '', ''),
(@max_id+1, 'fr_FR', 'Remboursement de la différence', '', '', '');
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://thelia.net/schema/dic/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<loops>
<loop name="credit-note" class="CreditNote\Loop\CreditNote" />
<loop name="credit-note-type" class="CreditNote\Loop\CreditNoteType" />
<loop name="credit-note-status" class="CreditNote\Loop\CreditNoteStatus" />
<loop name="credit-note-comment" class="CreditNote\Loop\CreditNoteComment" />
<loop name="credit-note-version" class="CreditNote\Loop\CreditNoteVersion" />
<loop name="credit-note-address" class="CreditNote\Loop\CreditNoteAddress" />
<loop name="credit-note-detail" class="CreditNote\Loop\CreditNoteDetail" />
<loop name="order-credit-note" class="CreditNote\Loop\OrderCreditNote" />
</loops>
<forms>
<form name="credit-note.create" class="CreditNote\Form\CreditNoteCreateForm" />
<form name="credit-note.empty" class="CreditNote\Form\CreditNoteEmptyForm" />
</forms>
<services>
<service id="creditnote.listener" class="CreditNote\EventListener\CreditNoteListener">
<tag name="kernel.event_subscriber" />
</service>
<service id="creditnote.smarty.plugin.format" class="CreditNote\Smarty\Plugins\CreditNoteFormat">
<argument type="service" id="request_stack"/>
<tag name="thelia.parser.register_plugin"/>
</service>
</services>
<hooks>
<hook id="creditnote.hook.back.order_edit" class="CreditNote\Hook\Back\OrderEditHook">
<tag name="hook.event_listener" event="order.tab" type="back" method="onOrderTab" />
<tag name="hook.event_listener" event="order-edit.bottom" type="back" method="onOrderEditBottom" />
<tag name="hook.event_listener" event="order.edit-js" type="back" method="onOrderEditJs" />
<tag name="hook.event_listener" event="order-edit.product-list" type="back" method="onOrderEditProductList" />
</hook>
<hook id="creditnote.hook.back.customer_edit" class="CreditNote\Hook\Back\CustomerEditHook">
<tag name="hook.event_listener" event="customer.edit" type="back" method="onCustomerEdit" />
<tag name="hook.event_listener" event="customer-edit.bottom" type="back" method="onCustomerEditBottom" />
<tag name="hook.event_listener" event="customer.edit-js" type="back" method="onCustomerEditJs" />
</hook>
<hook id="creditnote.hook.back.main" class="CreditNote\Hook\Back\MainHook">
<tag name="hook.event_listener" event="main.footer-js" type="back" method="onMainFooterJs" />
</hook>
</hooks>
</config>

View File

@@ -0,0 +1,47 @@
SET FOREIGN_KEY_CHECKS = 0;
INSERT INTO `credit_note_status` (`id`, `code`, `position`, `color`, `invoiced`, `used`, `created_at`, `updated_at`) VALUES
(1, 'proposed', 1, '#999966', 0, 0, NOW(), NOW()),
(2, 'refused', 2, '#e60000', 0, 0, NOW(), NOW()),
(3, 'accepted', 3, '#00cc00', 1, 0, NOW(), NOW()),
(4, 'used', 4, '#3399ff', 1, 1, NOW(), NOW());
INSERT INTO `credit_note_status_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES
(1, 'en_US', 'Proposed', '', '', ''),
(1, 'fr_FR', 'Proposé', '', '', ''),
(2, 'en_US', 'Refused', '', '', ''),
(2, 'fr_FR', 'Refusé', '', '', ''),
(3, 'en_US', 'Accepted', '', '', ''),
(3, 'fr_FR', 'Accepté', '', '', ''),
(4, 'en_US', 'Used', '', '', ''),
(4, 'fr_FR', 'Utilisé', '', '', '');
INSERT INTO `credit_note_status_flow` (`id`, `from_status_id`, `to_status_id`, `priority`, `root`, `created_at`, `updated_at`) VALUES
(1, 1, 2, 1, 1, NOW(), NOW()),
(2, 1, 3, 1, 0, NOW(), NOW()),
(3, 2, 1, 1, 1, NOW(), NOW()),
(4, 3, 4, 1, 0, NOW(), NOW());
INSERT INTO `credit_note_type` (`id`, `code`, `position`, `color`, `required_order`, `created_at`, `updated_at`) VALUES
(1, 'order_full_refund', 1, '#1abc9c', 1, NOW(), NOW()),
(2, 'back_product', 2, '#40d47e', 1, NOW(), NOW()),
(3, 'billing_error', 3, '#3498db', 1, NOW(), NOW()),
(4, 'rebate', 4, '#9b59b6', 0, NOW(), NOW()),
(5, 'discount', 5, '#34495e', 0, NOW(), NOW()),
(6, 'difference_refund', 5, '#CF7973', 0, NOW(), NOW());
INSERT INTO `credit_note_type_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES
(1, 'en_US', 'Order Full refund', '', '', ''),
(1, 'fr_FR', 'Remboursement complet', '', '', ''),
(2, 'en_US', 'Back Product', '', '', ''),
(2, 'fr_FR', 'Retour produit', '', '', ''),
(3, 'en_US', 'Billing error', '', '', ''),
(3, 'fr_FR', 'Erreur de facturation', '', '', ''),
(4, 'en_US', 'A rebate', '', '', ''),
(4, 'fr_FR', 'Un rabais', '', '', ''),
(5, 'en_US', 'A discount', '', '', ''),
(5, 'fr_FR', 'Une remise', '', '', ''),
(6, 'en_US', 'Difference refund', '', '', ''),
(6, 'fr_FR', 'Remboursement de la différence', '', '', '');
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="http://thelia.net/schema/dic/module"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_1.xsd">
<fullnamespace>CreditNote\CreditNote</fullnamespace>
<descriptive locale="en_US">
<title>Credit notes</title>
<subtitle>Allows granting credit notes to customers</subtitle>
</descriptive>
<descriptive locale="fr_FR">
<title>Avoirs</title>
<subtitle>Permet d'accorder des avoirs aux clients</subtitle>
</descriptive>
<languages>
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>2.3.3</version>
<author>
<name>Gilles Bourgeat</name>
<email>gbourgeat@openstudio.fr</email>
</author>
<type>classic</type>
<thelia>2.3.0</thelia>
<stability>beta</stability>
</module>

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="admin.order.pdf.invoice" path="/admin/credit-note/pdf/invoice/{creditNoteId}/{browser}">
<default key="_controller">CreditNote:CreditNote:generateInvoicePdf</default>
<default key="browser">0</default>
<requirement key="browser">[0|1|2]</requirement>
<requirement key="creditNoteId">\d+</requirement>
</route>
<route id="creditnote.list" path="/admin/credit-note">
<default key="_controller">CreditNote:CreditNote:list</default>
</route>
<route id="creditnote.ajax.modal.create" path="/admin/credit-note/ajax/modal/create">
<default key="_controller">CreditNote:CreditNote:ajaxModalCreate</default>
</route>
<route id="creditnote.create" path="/admin/credit-note/create">
<default key="_controller">CreditNote:CreditNote:create</default>
</route>
<route id="creditnote.view" path="/admin/credit-note/{id}">
<default key="_controller">CreditNote:CreditNote:view</default>
<requirement key="id">\d+</requirement>
</route>
<route id="creditnote.update" path="/admin/credit-note/{id}/_update" methods="post">
<default key="_controller">CreditNote:CreditNote:update</default>
<requirement key="id">\d+</requirement>
</route>
<route id="creditnote.delete" path="/admin/credit-note/{id}/_delete" methods="post">
<default key="_controller">CreditNote:CreditNote:delete</default>
<requirement key="id">\d+</requirement>
</route>
<route id="creditnote.ajax.search.customer" path="/admin/credit-note/ajax/search/customer" methods="get">
<default key="_controller">CreditNote:CreditNote:searchCustomer</default>
</route>
<route id="creditnote.ajax.search.order" path="/admin/credit-note/ajax/search/order" methods="get">
<default key="_controller">CreditNote:CreditNote:searchOrder</default>
</route>
<route id="creditnote.ajax.load.order" path="/admin/credit-note/ajax/load/order/{id}" methods="get">
<default key="_controller">CreditNote:CreditNote:loadOrder</default>
</route>
<route id="creditnote.configuration.default" path="/admin/module/CreditNote" methods="get">
<default key="_controller">CreditNote:CreditNoteConfig:default</default>
</route>
<route id="creditnote.configuration.save" path="/admin/module/CreditNote" methods="post">
<default key="_controller">CreditNote:CreditNoteConfig:save</default>
</route>
<route id="creditnote.configuration.default" path="/admin/module/CreditNote" methods="get">
<default key="_controller">CreditNote:CreditNoteConfig:default</default>
</route>
<route id="creditnote.order_credit_note.create" path="/admin/module/CreditNote/order_credit_note" methods="post">
<default key="_controller">CreditNote:OrderCreditNote:create</default>
</route>
</routes>

View File

@@ -0,0 +1,286 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../core/vendor/propel/propel/resources/xsd/database.xsd" >
<table name="credit_note" namespace="CreditNote\Model">
<column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
<column name="ref" type="VARCHAR" size="45" />
<column name="invoice_ref" type="VARCHAR" size="45" />
<column name="invoice_address_id" type="INTEGER" required="true" />
<column name="invoice_date" type="TIMESTAMP" />
<column name="order_id" type="INTEGER" required="false" />
<column name="customer_id" type="INTEGER" required="true" />
<column name="parent_id" type="INTEGER" required="false" />
<column name="type_id" type="INTEGER" required="true" />
<column name="status_id" type="INTEGER" required="true" />
<column name="currency_id" type="INTEGER" required="true" />
<column name="currency_rate" type="FLOAT" />
<column name="total_price" type="DECIMAL" scale="6" size="16" defaultValue="0.000000" />
<column name="total_price_with_tax" type="DECIMAL" scale="6" size="16" defaultValue="0.000000" />
<column name="discount_without_tax" type="DECIMAL" scale="6" size="16" defaultValue="0.000000" />
<column name="discount_with_tax" type="DECIMAL" scale="6" size="16" defaultValue="0.000000" />
<column name="allow_partial_use" type="BOOLEAN" defaultValue="1" />
<foreign-key foreignTable="order" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="order_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="customer" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="customer_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="credit_note" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="parent_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="credit_note_type" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="type_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="credit_note_status" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="status_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="currency" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="currency_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="credit_note_address" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="invoice_address_id" foreign="id" />
</foreign-key>
<unique name="ref_UNIQUE">
<unique-column name="ref" />
</unique>
<unique name="invoice_ref_UNIQUE">
<unique-column name="invoice_ref" />
</unique>
<index name="idx_order_id_fk">
<index-column name="order_id" />
</index>
<index name="idx_customer_id_fk">
<index-column name="customer_id" />
</index>
<index name="idx_parent_id_fk">
<index-column name="parent_id" />
</index>
<index name="idx_type_id_fk">
<index-column name="type_id" />
</index>
<index name="idx_status_id_fk">
<index-column name="status_id" />
</index>
<behavior name="timestampable" />
<behavior name="versionable">
<parameter name="log_created_at" value="true" />
<parameter name="log_created_by" value="true" />
</behavior>
</table>
<table name="credit_note_address" namespace="CreditNote\Model">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
<column name="customer_title_id" type="INTEGER" />
<column name="company" size="255" type="VARCHAR" />
<column name="firstname" required="true" size="255" type="VARCHAR" />
<column name="lastname" required="true" size="255" type="VARCHAR" />
<column name="address1" required="true" size="255" type="VARCHAR" />
<column name="address2" size="255" type="VARCHAR" />
<column name="address3" size="255" type="VARCHAR" />
<column name="zipcode" required="true" size="10" type="VARCHAR" />
<column name="city" required="true" size="255" type="VARCHAR" />
<column name="phone" size="20" type="VARCHAR" />
<column name="cellphone" size="20" type="VARCHAR" />
<column name="country_id" required="true" type="INTEGER" />
<column name="state_id" type="INTEGER" />
<foreign-key foreignTable="customer_title" name="fk_credit_note_address_customer_title_id" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference foreign="id" local="customer_title_id" />
</foreign-key>
<foreign-key foreignTable="country" name="fk_credit_note_address_country_id" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference foreign="id" local="country_id" />
</foreign-key>
<foreign-key foreignTable="state" name="fk_credit_note_address_state_id" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference foreign="id" local="state_id" />
</foreign-key>
<behavior name="timestampable" />
</table>
<table name="order_credit_note" namespace="CreditNote\Model">
<column name="order_id" type="INTEGER" required="true" primaryKey="true" />
<column name="credit_note_id" type="INTEGER" required="true" primaryKey="true" />
<column name="amount_price" type="DECIMAL" scale="6" size="16" defaultValue="0.000000" />
<foreign-key foreignTable="order" onDelete="CASCADE" onUpdate="RESTRICT">
<reference local="order_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="credit_note" onDelete="CASCADE" onUpdate="RESTRICT">
<reference local="credit_note_id" foreign="id" />
</foreign-key>
<behavior name="timestampable" />
</table>
<table name="cart_credit_note" namespace="CreditNote\Model">
<column name="cart_id" type="INTEGER" required="true" primaryKey="true" />
<column name="credit_note_id" type="INTEGER" required="true" primaryKey="true" />
<column name="amount_price" type="DECIMAL" scale="6" size="16" defaultValue="0.000000" />
<foreign-key foreignTable="cart" onDelete="CASCADE" onUpdate="RESTRICT">
<reference local="cart_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="credit_note" onDelete="CASCADE" onUpdate="RESTRICT">
<reference local="credit_note_id" foreign="id" />
</foreign-key>
<behavior name="timestampable" />
</table>
<table name="credit_note_status" namespace="CreditNote\Model">
<column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
<column name="code" type="VARCHAR" size="45" />
<column name="color" type="CHAR" size="7" />
<column name="invoiced" type="BOOLEAN" required="true" defaultValue="0" />
<column name="used" type="BOOLEAN" required="true" defaultValue="0" />
<column name="position" type="INTEGER" size="11" />
<column name="title" type="VARCHAR" size="255" />
<column name="description" type="CLOB" />
<column name="chapo" type="LONGVARCHAR" />
<column name="postscriptum" type="LONGVARCHAR" />
<behavior name="i18n">
<parameter name="i18n_columns" value="title, description, chapo, postscriptum" />
</behavior>
<behavior name="timestampable" />
</table>
<table name="credit_note_status_flow" namespace="CreditNote\Model">
<column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
<column name="from_status_id" type="INTEGER" required="true" />
<column name="to_status_id" type="INTEGER" required="true" />
<column name="priority" type="INTEGER" size="11" />
<column name="root" type="BOOLEAN" required="true" defaultValue="0" />
<foreign-key name="credit_note_status_flow_credit_note_status_from" foreignTable="credit_note_status" onDelete="CASCADE" onUpdate="RESTRICT">
<reference local="from_status_id" foreign="id" />
</foreign-key>
<foreign-key name="credit_note_status_flow_credit_note_status_to" foreignTable="credit_note_status" onDelete="CASCADE" onUpdate="RESTRICT">
<reference local="to_status_id" foreign="id" />
</foreign-key>
<behavior name="timestampable" />
</table>
<table name="credit_note_type" namespace="CreditNote\Model">
<column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
<column name="code" type="VARCHAR" size="45" />
<column name="color" type="CHAR" size="7" />
<column name="position" type="INTEGER" size="11" />
<column name="required_order" type="BOOLEAN" required="true" defaultValue="0" />
<column name="title" type="VARCHAR" size="255" />
<column name="description" type="CLOB" />
<column name="chapo" type="LONGVARCHAR" />
<column name="postscriptum" type="LONGVARCHAR" />
<behavior name="i18n">
<parameter name="i18n_columns" value="title, description, chapo, postscriptum" />
</behavior>
<behavior name="timestampable" />
</table>
<table name="credit_note_detail" namespace="CreditNote\Model">
<column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
<column name="credit_note_id" type="INTEGER" required="true" />
<column name="price" type="DECIMAL" scale="6" size="16" defaultValue="0.000000" />
<column name="price_with_tax" type="DECIMAL" scale="6" size="16" defaultValue="0.000000" />
<column name="tax_rule_id" type="INTEGER" required="false" />
<column name="order_product_id" type="INTEGER" required="false" />
<column name="type" type="VARCHAR" size="55" />
<column name="quantity" defaultValue="0" required="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="255" />
<foreign-key foreignTable="credit_note" onDelete="CASCADE" onUpdate="RESTRICT">
<reference local="credit_note_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="order_product" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="order_product_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="tax_rule" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference local="tax_rule_id" foreign="id" />
</foreign-key>
<index name="idx_credit_note_id_fk">
<index-column name="credit_note_id" />
</index>
<index name="idx_order_product_id_fk">
<index-column name="order_product_id" />
</index>
<behavior name="timestampable" />
</table>
<table name="credit_note_comment" namespace="CreditNote\Model">
<column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
<column name="credit_note_id" type="INTEGER" required="true" />
<column name="admin_id" type="INTEGER" required="false" />
<column name="comment" type="CLOB" />
<foreign-key foreignTable="credit_note" onDelete="CASCADE" onUpdate="RESTRICT">
<reference local="credit_note_id" foreign="id" />
</foreign-key>
<foreign-key foreignTable="admin" onDelete="SET NULL" onUpdate="RESTRICT">
<reference local="admin_id" foreign="id" />
</foreign-key>
<index name="idx_credit_note_id_fk">
<index-column name="credit_note_id" />
</index>
<index name="idx_admin_id_fk">
<index-column name="admin_id" />
</index>
<behavior name="timestampable" />
</table>
<external-schema filename="local/config/schema.xml" referenceOnly="true" />
</database>

View File

@@ -0,0 +1,403 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- credit_note
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note`;
CREATE TABLE `credit_note`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`ref` VARCHAR(45),
`invoice_ref` VARCHAR(45),
`invoice_address_id` INTEGER NOT NULL,
`invoice_date` DATETIME,
`order_id` INTEGER,
`customer_id` INTEGER NOT NULL,
`parent_id` INTEGER,
`type_id` INTEGER NOT NULL,
`status_id` INTEGER NOT NULL,
`currency_id` INTEGER NOT NULL,
`currency_rate` FLOAT,
`total_price` DECIMAL(16,6) DEFAULT 0.000000,
`total_price_with_tax` DECIMAL(16,6) DEFAULT 0.000000,
`discount_without_tax` DECIMAL(16,6) DEFAULT 0.000000,
`discount_with_tax` DECIMAL(16,6) DEFAULT 0.000000,
`allow_partial_use` TINYINT(1) DEFAULT 1,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`),
UNIQUE INDEX `ref_UNIQUE` (`ref`),
UNIQUE INDEX `invoice_ref_UNIQUE` (`invoice_ref`),
INDEX `idx_order_id_fk` (`order_id`),
INDEX `idx_customer_id_fk` (`customer_id`),
INDEX `idx_parent_id_fk` (`parent_id`),
INDEX `idx_type_id_fk` (`type_id`),
INDEX `idx_status_id_fk` (`status_id`),
INDEX `credit_note_fi_16a5a4` (`currency_id`),
INDEX `credit_note_fi_665c7d` (`invoice_address_id`),
CONSTRAINT `credit_note_fk_75704f`
FOREIGN KEY (`order_id`)
REFERENCES `order` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT,
CONSTRAINT `credit_note_fk_7e8f3e`
FOREIGN KEY (`customer_id`)
REFERENCES `customer` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT,
CONSTRAINT `credit_note_fk_a814f7`
FOREIGN KEY (`parent_id`)
REFERENCES `credit_note` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT,
CONSTRAINT `credit_note_fk_b18ffb`
FOREIGN KEY (`type_id`)
REFERENCES `credit_note_type` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT,
CONSTRAINT `credit_note_fk_2bb7af`
FOREIGN KEY (`status_id`)
REFERENCES `credit_note_status` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT,
CONSTRAINT `credit_note_fk_16a5a4`
FOREIGN KEY (`currency_id`)
REFERENCES `currency` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT,
CONSTRAINT `credit_note_fk_665c7d`
FOREIGN KEY (`invoice_address_id`)
REFERENCES `credit_note_address` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- credit_note_address
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note_address`;
CREATE TABLE `credit_note_address`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`customer_title_id` INTEGER,
`company` VARCHAR(255),
`firstname` VARCHAR(255) NOT NULL,
`lastname` VARCHAR(255) NOT NULL,
`address1` VARCHAR(255) NOT NULL,
`address2` VARCHAR(255),
`address3` VARCHAR(255),
`zipcode` VARCHAR(10) NOT NULL,
`city` VARCHAR(255) NOT NULL,
`phone` VARCHAR(20),
`cellphone` VARCHAR(20),
`country_id` INTEGER NOT NULL,
`state_id` INTEGER,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `fi_credit_note_address_customer_title_id` (`customer_title_id`),
INDEX `fi_credit_note_address_country_id` (`country_id`),
INDEX `fi_credit_note_address_state_id` (`state_id`),
CONSTRAINT `fk_credit_note_address_customer_title_id`
FOREIGN KEY (`customer_title_id`)
REFERENCES `customer_title` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT,
CONSTRAINT `fk_credit_note_address_country_id`
FOREIGN KEY (`country_id`)
REFERENCES `country` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT,
CONSTRAINT `fk_credit_note_address_state_id`
FOREIGN KEY (`state_id`)
REFERENCES `state` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- order_credit_note
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `order_credit_note`;
CREATE TABLE `order_credit_note`
(
`order_id` INTEGER NOT NULL,
`credit_note_id` INTEGER NOT NULL,
`amount_price` DECIMAL(16,6) DEFAULT 0.000000,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`order_id`,`credit_note_id`),
INDEX `order_credit_note_fi_ef6fa8` (`credit_note_id`),
CONSTRAINT `order_credit_note_fk_75704f`
FOREIGN KEY (`order_id`)
REFERENCES `order` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE,
CONSTRAINT `order_credit_note_fk_ef6fa8`
FOREIGN KEY (`credit_note_id`)
REFERENCES `credit_note` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- cart_credit_note
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `cart_credit_note`;
CREATE TABLE `cart_credit_note`
(
`cart_id` INTEGER NOT NULL,
`credit_note_id` INTEGER NOT NULL,
`amount_price` DECIMAL(16,6) DEFAULT 0.000000,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`cart_id`,`credit_note_id`),
INDEX `cart_credit_note_fi_ef6fa8` (`credit_note_id`),
CONSTRAINT `cart_credit_note_fk_3ffb24`
FOREIGN KEY (`cart_id`)
REFERENCES `cart` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE,
CONSTRAINT `cart_credit_note_fk_ef6fa8`
FOREIGN KEY (`credit_note_id`)
REFERENCES `credit_note` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- credit_note_status
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note_status`;
CREATE TABLE `credit_note_status`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`code` VARCHAR(45),
`color` CHAR(7),
`invoiced` TINYINT(1) DEFAULT 0 NOT NULL,
`used` TINYINT(1) DEFAULT 0 NOT NULL,
`position` INTEGER(11),
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- credit_note_status_flow
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note_status_flow`;
CREATE TABLE `credit_note_status_flow`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`from_status_id` INTEGER NOT NULL,
`to_status_id` INTEGER NOT NULL,
`priority` INTEGER(11),
`root` TINYINT(1) DEFAULT 0 NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `fi_dit_note_status_flow_credit_note_status_from` (`from_status_id`),
INDEX `fi_dit_note_status_flow_credit_note_status_to` (`to_status_id`),
CONSTRAINT `credit_note_status_flow_credit_note_status_from`
FOREIGN KEY (`from_status_id`)
REFERENCES `credit_note_status` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE,
CONSTRAINT `credit_note_status_flow_credit_note_status_to`
FOREIGN KEY (`to_status_id`)
REFERENCES `credit_note_status` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- credit_note_type
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note_type`;
CREATE TABLE `credit_note_type`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`code` VARCHAR(45),
`color` CHAR(7),
`position` INTEGER(11),
`required_order` TINYINT(1) DEFAULT 0 NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- credit_note_detail
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note_detail`;
CREATE TABLE `credit_note_detail`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`credit_note_id` INTEGER NOT NULL,
`price` DECIMAL(16,6) DEFAULT 0.000000,
`price_with_tax` DECIMAL(16,6) DEFAULT 0.000000,
`tax_rule_id` INTEGER,
`order_product_id` INTEGER,
`type` VARCHAR(55),
`quantity` INTEGER DEFAULT 0 NOT NULL,
`title` VARCHAR(255),
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_credit_note_id_fk` (`credit_note_id`),
INDEX `idx_order_product_id_fk` (`order_product_id`),
INDEX `credit_note_detail_fi_02f8ad` (`tax_rule_id`),
CONSTRAINT `credit_note_detail_fk_ef6fa8`
FOREIGN KEY (`credit_note_id`)
REFERENCES `credit_note` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE,
CONSTRAINT `credit_note_detail_fk_6df978`
FOREIGN KEY (`order_product_id`)
REFERENCES `order_product` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT,
CONSTRAINT `credit_note_detail_fk_02f8ad`
FOREIGN KEY (`tax_rule_id`)
REFERENCES `tax_rule` (`id`)
ON UPDATE RESTRICT
ON DELETE RESTRICT
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- credit_note_comment
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note_comment`;
CREATE TABLE `credit_note_comment`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`credit_note_id` INTEGER NOT NULL,
`admin_id` INTEGER,
`comment` LONGTEXT,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`),
INDEX `idx_credit_note_id_fk` (`credit_note_id`),
INDEX `idx_admin_id_fk` (`admin_id`),
CONSTRAINT `credit_note_comment_fk_ef6fa8`
FOREIGN KEY (`credit_note_id`)
REFERENCES `credit_note` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE,
CONSTRAINT `credit_note_comment_fk_8e51ba`
FOREIGN KEY (`admin_id`)
REFERENCES `admin` (`id`)
ON UPDATE RESTRICT
ON DELETE SET NULL
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- credit_note_status_i18n
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note_status_i18n`;
CREATE TABLE `credit_note_status_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
`chapo` TEXT,
`postscriptum` TEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `credit_note_status_i18n_fk_d8a515`
FOREIGN KEY (`id`)
REFERENCES `credit_note_status` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- credit_note_type_i18n
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note_type_i18n`;
CREATE TABLE `credit_note_type_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
`chapo` TEXT,
`postscriptum` TEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `credit_note_type_i18n_fk_90b79e`
FOREIGN KEY (`id`)
REFERENCES `credit_note_type` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- credit_note_version
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `credit_note_version`;
CREATE TABLE `credit_note_version`
(
`id` INTEGER NOT NULL,
`ref` VARCHAR(45),
`invoice_ref` VARCHAR(45),
`invoice_address_id` INTEGER NOT NULL,
`invoice_date` DATETIME,
`order_id` INTEGER,
`customer_id` INTEGER NOT NULL,
`parent_id` INTEGER,
`type_id` INTEGER NOT NULL,
`status_id` INTEGER NOT NULL,
`currency_id` INTEGER NOT NULL,
`currency_rate` FLOAT,
`total_price` DECIMAL(16,6) DEFAULT 0.000000,
`total_price_with_tax` DECIMAL(16,6) DEFAULT 0.000000,
`discount_without_tax` DECIMAL(16,6) DEFAULT 0.000000,
`discount_with_tax` DECIMAL(16,6) DEFAULT 0.000000,
`allow_partial_use` TINYINT(1) DEFAULT 1,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0 NOT NULL,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
`order_id_version` INTEGER DEFAULT 0,
`customer_id_version` INTEGER DEFAULT 0,
`parent_id_version` INTEGER DEFAULT 0,
`credit_note_ids` TEXT,
`credit_note_versions` TEXT,
PRIMARY KEY (`id`,`version`),
CONSTRAINT `credit_note_version_fk_f2e1e2`
FOREIGN KEY (`id`)
REFERENCES `credit_note` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,904 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Controller;
use CreditNote\Helper\CreditNoteHelper;
use CreditNote\Helper\CriteriaSearchHelper;
use CreditNote\Model\Base\CreditNoteStatusQuery;
use CreditNote\Model\CreditNote;
use CreditNote\Model\CreditNoteAddress;
use CreditNote\Model\CreditNoteComment;
use CreditNote\Model\CreditNoteDetail;
use CreditNote\Model\CreditNoteDetailQuery;
use CreditNote\Model\CreditNoteQuery;
use CreditNote\Model\CreditNoteTypeQuery;
use CreditNote\Model\Map\CreditNoteTableMap;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Propel\Runtime\Propel;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\Event\PdfEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\HttpFoundation\JsonResponse;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\Thelia;
use Thelia\Exception\TheliaProcessException;
use Thelia\Log\Tlog;
use Thelia\Model\AddressQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Customer;
use Thelia\Model\CustomerQuery;
use Thelia\Model\Map\AddressTableMap;
use Thelia\Model\Map\OrderAddressTableMap;
use Thelia\Model\Order;
use Thelia\Model\OrderProductTax;
use Thelia\Model\OrderQuery;
use Thelia\Model\ProductSaleElementsQuery;
use Thelia\Model\TaxRuleQuery;
use Thelia\Tools\URL;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*/
class CreditNoteController extends BaseAdminController
{
use CriteriaSearchHelper;
/**
* @param Request $request
* @return \Thelia\Core\HttpFoundation\Response
*/
public function listAction(Request $request)
{
return $this->render(
"credit-note-list",
[
]
);
}
/**
* @param Request $request
* @param int $id
* @return \Thelia\Core\HttpFoundation\Response
*/
public function viewAction(Request $request, $id)
{
$creditNote = CreditNoteQuery::create()
->filterById($id, Criteria::EQUAL)
->findOne();
$creditNote = $this->performCreditNote($creditNote);
return $this->render("ajax/credit-note-modal", [
'creditNote' => $creditNote
]);
}
public function createAction(Request $request)
{
$creditNote = $this->performCreditNote();
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
try {
$creditNote->save();
$con->commit();
} catch (\Exception $e) {
$con->rollBack();
throw $e;
}
if (null !== $request->get('success-url')) {
return new RedirectResponse($request->get('success-url'));
}
if (null !== $creditNote->getOrder()) {
return $this->generateRedirectFromRoute(
'admin.order.update.view',
[
'tab' => 'credit-note'
],
[
'order_id' => $creditNote->getOrder()->getId()
]
);
}
if (null !== $creditNote->getCustomer()) {
return $this->generateRedirectFromRoute('admin.customer.update.view', [], [
'customer_id' => $creditNote->getCustomer()->getId()
]);
}
}
public function updateAction(Request $request, $id)
{
$creditNote = CreditNoteQuery::create()
->filterById($id, Criteria::EQUAL)
->findOne();
$creditNote = $this->performCreditNote($creditNote);
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
try {
$creditNote->save();
$con->commit();
} catch (\Exception $e) {
$con->rollBack();
throw $e;
}
if (null !== $request->get('success-url')) {
return new RedirectResponse($request->get('success-url'));
}
if (null !== $creditNote->getOrder()) {
return $this->generateRedirectFromRoute(
'admin.order.update.view',
[
'tab' => 'credit-note'
],
[
'order_id' => $creditNote->getOrder()->getId()
]
);
}
if (null !== $creditNote->getCustomer()) {
return $this->generateRedirectFromRoute('admin.customer.update.view', [], [
'customer_id' => $creditNote->getCustomer()->getId()
]);
}
}
public function deleteAction(Request $request, $id)
{
$creditNote = CreditNoteQuery::create()->findOneById($id);
if (!empty($creditNote->getInvoiceRef())) {
$request->getSession()->getFlashBag()->set(
'error',
$this->getTranslator()->trans(
"You can not delete this credit note"
)
);
} else {
CreditNoteQuery::create()->filterById($id)->delete();
}
if (null !== $request->get('success-url')) {
return new RedirectResponse($request->get('success-url'));
}
if (null !== $creditNote->getOrder()) {
return $this->generateRedirectFromRoute(
'admin.order.update.view',
[
'tab' => 'credit-note'
],
[
'order_id' => $creditNote->getOrder()->getId()
]
);
}
if (null !== $creditNote->getCustomer()) {
return $this->generateRedirectFromRoute('admin.customer.update.view', [], [
'customer_id' => $creditNote->getCustomer()->getId()
]);
}
}
/**
* @param Request $request
* @return \Thelia\Core\HttpFoundation\Response
*/
public function ajaxModalCreateAction(Request $request)
{
$creditNote = $this->performCreditNote();
return $this->render("ajax/credit-note-modal", [
'creditNote' => $creditNote
]);
}
public function generateInvoicePdfAction($creditNoteId, $browser)
{
return $this->generateCreditNotePdf($creditNoteId, 'credit-note', true, true, $browser);
}
/**
* @param int $creditNoteId
* @param string $fileName
* @param bool $checkCreditNoteStatus
* @param bool $checkAdminUser
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function generateCreditNotePdf($creditNoteId, $fileName, $checkCreditNoteStatus = true, $checkAdminUser = true, $browser = false)
{
$creditNote = CreditNoteQuery::create()->findPk($creditNoteId);
// check if the order has the paid status
if ($checkAdminUser && !$this->getSecurityContext()->hasAdminUser()) {
throw new NotFoundHttpException();
}
if ($checkCreditNoteStatus && !$creditNote->getCreditNoteStatus()->getInvoiced()) {
throw new NotFoundHttpException();
}
$html = $this->renderRaw(
$fileName,
[
'credit_note_id' => $creditNote->getId()
],
$this->getTemplateHelper()->getActivePdfTemplate()
);
if ((int) $browser === 2) {
return new Response($html);
}
try {
$pdfEvent = new PdfEvent($html);
$this->dispatch(TheliaEvents::GENERATE_PDF, $pdfEvent);
if ($pdfEvent->hasPdf()) {
if ((int) $browser === 1) {
$browser = true;
} else {
$browser = false;
}
return $this->pdfResponse($pdfEvent->getPdf(), $creditNote->getInvoiceRef(), 200, $browser);
}
} catch (\Exception $e) {
Tlog::getInstance()->error(
sprintf(
'error during generating invoice pdf for credit note id : %d with message "%s"',
$creditNote->getId(),
$e->getMessage()
)
);
}
throw new TheliaProcessException(
$this->getTranslator()->trans(
"We're sorry, this PDF invoice is not available at the moment."
)
);
}
/**
* @return CreditNote
*/
protected function performCreditNote(CreditNote $creditNote = null)
{
if (null === $creditNote) {
$creditNote = new CreditNote();
}
$creditNote->setDispatcher($this->getDispatcher());
$form = $this->createForm('credit-note.create', 'form', [], ['csrf_protection' => false]);
$formValidate = $this->validateForm($form, 'post');
if (null === $creditNote->getInvoiceRef()) {
$this
->performType($formValidate, $creditNote)
->performOrder($formValidate, $creditNote)
->performCurrency($formValidate, $creditNote)
->performCustomer($formValidate, $creditNote)
->performInvoiceAddress($formValidate, $creditNote)
->performStatus($formValidate, $creditNote)
->performFreeAmounts($formValidate, $creditNote)
->performOrderProducts($formValidate, $creditNote)
->performDiscount($formValidate, $creditNote)
->performAmount($formValidate, $creditNote)
;
}
$this->performComment($formValidate, $creditNote);
$this->getParserContext()->addForm($form);
$creditNote->setDispatcher($this->getDispatcher());
return $creditNote;
}
protected function performDiscount(Form $formValidate, CreditNote $creditNote)
{
$discountWithoutTax = $formValidate->get('discount_without_tax')->getData();
$discountWithTax = $formValidate->get('discount_with_tax')->getData();
if (null !== $creditNote->getOrder() && $creditNote->getCreditNoteType()->getCode() === CreditNoteHelper::TYPE_ORDER_FULL_REFUND) {
$creditNote->setDiscountWithoutTax($creditNote->getOrder()->getDiscount());
$creditNote->setDiscountWithTax($creditNote->getOrder()->getDiscount());
} elseif (null !== $discountWithoutTax && null !== $discountWithTax) {
$creditNote->setDiscountWithoutTax($discountWithoutTax);
$creditNote->setDiscountWithTax($discountWithTax);
} elseif (null === $creditNote->getOrder()) {
$creditNote->setDiscountWithoutTax(0);
$creditNote->setDiscountWithTax(0);
}
return $this;
}
protected function performInvoiceAddress(Form $formValidate, CreditNote $creditNote)
{
if (!empty($creditNote->getInvoiceRef())) {
return $this;
}
$action = $formValidate->get('action')->getData();
$invoiceAddressId = $formValidate->get('invoice_address_id')->getData();
if ($action !== 'view') {
$creditNoteAddress = $creditNote->getCreditNoteAddress();
if (null === $creditNoteAddress) {
$creditNoteAddress = new CreditNoteAddress();
}
if (null === $creditNote->getCustomer()) {
$creditNoteAddress = new CreditNoteAddress();
} elseif ($invoiceAddressId) {
$address = AddressQuery::create()->findOneById((int)$invoiceAddressId);
$customerTitle = $address->getCustomerTitle();
$creditNoteAddress
->setCustomerTitleId($customerTitle ? $customerTitle->getId() : null)
->setAddress1($address->getAddress1())
->setAddress2($address->getAddress2())
->setAddress3($address->getAddress3())
->setFirstname($address->getFirstname())
->setLastname($address->getLastname())
->setCity($address->getCity())
->setZipcode($address->getZipcode())
->setCompany($address->getCompany())
->setCountryId($address->getCountry()->getId());
} else {
$invoiceAddressTitle = $formValidate->get('invoice_address_title')->getData();
$invoiceAddressFirstname = $formValidate->get('invoice_address_firstname')->getData();
$invoiceAddressLastname = $formValidate->get('invoice_address_lastname')->getData();
$invoiceAddressCompany = $formValidate->get('invoice_address_company')->getData();
$invoiceAddressAddress1 = $formValidate->get('invoice_address_address1')->getData();
$invoiceAddressAddress2 = $formValidate->get('invoice_address_address2')->getData();
$invoiceAddressZipcode = $formValidate->get('invoice_address_zipcode')->getData();
$invoiceAddressCity = $formValidate->get('invoice_address_city')->getData();
$invoiceAddressCountryId = $formValidate->get('invoice_address_country_id')->getData();
$country = CountryQuery::create()->findOneById($invoiceAddressCountryId);
$creditNoteAddress
->setCustomerTitleId($invoiceAddressTitle)
->setAddress1($invoiceAddressAddress1)
->setAddress2($invoiceAddressAddress2)
->setFirstname($invoiceAddressFirstname)
->setLastname($invoiceAddressLastname)
->setCity($invoiceAddressCity)
->setZipcode($invoiceAddressZipcode)
->setCompany($invoiceAddressCompany)
->setCountryId(
$country ? $country->getId() : null
);
}
if (empty($creditNoteAddress->getLastname()) && ('create' === $action || 'update' === $action)) {
$formValidate->addError(
new FormError('Please select a invoice address')
);
$creditNoteAddress->save();
}
$creditNote->setCreditNoteAddress($creditNoteAddress);
} elseif (null === $creditNote->getId()) {
if (null !== $creditNote->getOrder() && null === $creditNote->getCreditNoteAddress()) {
$address = $creditNote->getOrder()->getOrderAddressRelatedByInvoiceOrderAddressId();
$customerTitle = $address->getCustomerTitle();
$creditNoteAddress = new CreditNoteAddress();
$creditNoteAddress
->setCustomerTitleId($customerTitle ? $customerTitle->getId() : null)
->setAddress1($address->getAddress1())
->setAddress2($address->getAddress2())
->setAddress3($address->getAddress3())
->setFirstname($address->getFirstname())
->setLastname($address->getLastname())
->setCity($address->getCity())
->setZipcode($address->getZipcode())
->setCompany($address->getCompany())
->setCountryId($address->getCountry()->getId());
$creditNote->setCreditNoteAddress($creditNoteAddress);
} else {
$creditNote->setCreditNoteAddress(new CreditNoteAddress());
}
}
return $this;
}
protected function performAmount(Form $formValidate, CreditNote $creditNote)
{
$totalPrice = 0;
$totalPriceWithTax = 0;
foreach ($creditNote->getCreditNoteDetails() as $creditNoteDetail) {
$totalPrice += $creditNoteDetail->getPrice() * $creditNoteDetail->getQuantity();
$totalPriceWithTax += $creditNoteDetail->getPriceWithTax() * $creditNoteDetail->getQuantity();
}
$totalPrice -= $creditNote->getDiscountWithoutTax();
$totalPriceWithTax -= $creditNote->getDiscountWithTax();
$creditNote->setTotalPrice($totalPrice);
$creditNote->setTotalPriceWithTax($totalPriceWithTax);
return $this;
}
protected function performComment(Form $formValidate, CreditNote $creditNote)
{
/** @var string $orderId */
$comment = trim($formValidate->get('comment')->getData());
if (null !== $comment && !empty($comment)) {
$creditNote->addCreditNoteComment(
(new CreditNoteComment())
->setComment($comment)
->setAdminId($this->getSecurityContext()->getAdminUser()->getId())
);
}
return $this;
}
protected function performOrder(Form $formValidate, CreditNote $creditNote)
{
/** @var int $orderId */
$orderId = $formValidate->get('order_id')->getData();
if (null !== $orderId && !empty($orderId)) {
$order = OrderQuery::create()->findPk($orderId);
$creditNote
->setOrder($order)
->setCustomer($order->getCustomer())
->setCurrency($order->getCurrency());
if ($order->getStatusId() == 1 || $order->getStatusId() == 5) {
throw new \Exception('This order is not invoiced');
}
}
return $this;
}
protected function performCurrency(Form $formValidate, CreditNote $creditNote)
{
/** @var int $currencyId */
$currencyId = $formValidate->get('currency_id')->getData();
if (null !== $creditNote->getOrder()) {
$creditNote->setCurrency($creditNote->getOrder()->getCurrency());
} elseif ($creditNote->getCurrency() === null) {
if (!empty($currencyId) && $currency = CurrencyQuery::create()->findPk($currencyId)) {
$creditNote->setCurrency($currency);
} else {
$creditNote->setCurrency(CurrencyQuery::create()->findOneByByDefault(true));
}
}
return $this;
}
protected function performCustomer(Form $formValidate, CreditNote $creditNote)
{
/** @var int $customerId */
$customerId = $formValidate->get('customer_id')->getData();
// check if order
if (!empty($orderId) && null !== $order = OrderQuery::create()->findPk($orderId)) {
$creditNote
->setOrder($order)
->setCurrency($order->getCurrency())
->setCustomer($order->getCustomer());
} elseif (!empty($customerId) && null !== $customer = CustomerQuery::create()->findPk($customerId)) {
$creditNote->setCustomer($customer);
}
return $this;
}
protected function performType(Form $formValidate, CreditNote $creditNote)
{
/** @var int $typeId */
$typeId = $formValidate->get('type_id')->getData();
if (!empty($typeId) && null !== $type = CreditNoteTypeQuery::create()->findPk($typeId)) {
$creditNote->setCreditNoteType($type);
} elseif (null === $creditNote->getTypeId()) {
$creditNote->setCreditNoteType(CreditNoteTypeQuery::create()->findOne());
}
return $this;
}
protected function performStatus(Form $formValidate, CreditNote $creditNote)
{
/** @var int $statusId */
$statusId = $formValidate->get('status_id')->getData();
if (!empty($statusId) && null !== $status = CreditNoteStatusQuery::create()->findPk($statusId)) {
$creditNote->setCreditNoteStatus($status);
} elseif (null === $creditNote->getStatusId()) {
$creditNote->setCreditNoteStatus(CreditNoteStatusQuery::create()->findOne());
}
return $this;
}
protected function performFreeAmounts(Form $formValidate, CreditNote $creditNote)
{
/** @var string[] $freeAmountTitles */
$freeAmountTitles = $formValidate->get('free_amount_title')->getData();
/** @var float[] $freeAmountPrices */
$freeAmountPrices = $formValidate->get('free_amount_price')->getData();
/** @var float[] $freeAmountPricesWithTax */
$freeAmountPricesWithTax = $formValidate->get('free_amount_price_with_tax')->getData();
/** @var int[] $freeAmountTaxRuleIds */
$freeAmountTaxRuleIds = $formValidate->get('free_amount_tax_rule_id')->getData();
/** @var string[] $freeAmountTaxRuleIds */
$freeAmountIds = $formValidate->get('free_amount_id')->getData();
/** @var string[] $freeAmountTypes */
$freeAmountTypes = $formValidate->get('free_amount_type')->getData();
/** @var string $freeAmountTypes */
$action = $formValidate->get('action')->getData();
foreach ($creditNote->getCreditNoteDetails() as $creditNoteDetail) {
if (empty($creditNoteDetail->getOrderProductId())) {
foreach ($freeAmountTitles as $key => $freeAmountTitle) {
if ($freeAmountIds[$key] == $creditNoteDetail->getId()) {
$creditNoteDetail
->setTitle($freeAmountTitle)
->setPrice($freeAmountPrices[$key])
->setTaxRuleId($freeAmountTaxRuleIds[$key])
->setType($freeAmountTypes[$key])
->setPriceWithTax($freeAmountPricesWithTax[$key]);
}
}
}
}
/**
* @var int $key
* @var int $freeAmountTitle
*/
foreach ($freeAmountTitles as $key => $freeAmountTitle) {
if (empty($freeAmountIds[$key])) {
$creditNote->addCreditNoteDetail(
(new CreditNoteDetail())
->setTitle($freeAmountTitle)
->setPrice($freeAmountPrices[$key])
->setTaxRuleId($freeAmountTaxRuleIds[$key])
->setType($freeAmountTypes[$key])
->setQuantity(1)
->setPriceWithTax($freeAmountPricesWithTax[$key])
);
}
}
if (null !== $creditNote->getOrder() && $creditNote->getCreditNoteType()->getCode() === CreditNoteHelper::TYPE_ORDER_FULL_REFUND) {
if (!(float) $creditNote->getOrder()->getPostage()) {
foreach ($creditNote->getCreditNoteDetails() as $creditNoteDetail) {
if ($creditNoteDetail->getType() == 'shipping') {
$creditNote->removeCreditNoteDetail($creditNoteDetail);
}
}
} else {
$findShipping = false;
foreach ($creditNote->getCreditNoteDetails() as $creditNoteDetail) {
if ($creditNoteDetail->getType() == 'shipping') {
$findShipping = true;
$creditNoteDetail
->setPrice(
$creditNote->getOrder()->getPostage() - $creditNote->getOrder()->getPostageTax()
)
->setPriceWithTax(
$creditNote->getOrder()->getPostage()
);
}
}
if (!$findShipping) {
$creditNote->addCreditNoteDetail(
(new CreditNoteDetail())
->setQuantity(1)
->setTitle('Frais de port')
->setPrice($creditNote->getOrder()->getPostage() - $creditNote->getOrder()->getPostageTax())
->setType('shipping')
->setPriceWithTax($creditNote->getOrder()->getPostage())
);
}
}
}
if ('refresh' === $action || $action === 'update') {
foreach ($creditNote->getCreditNoteDetails() as $creditNoteDetail) {
$find = false;
if (empty($creditNoteDetail->getOrderProductId())) {
foreach ($freeAmountTitles as $key => $freeAmountTitle) {
if ($freeAmountIds[$key] == $creditNoteDetail->getId()) {
$find = true;
}
}
if (!$find) {
$creditNote->removeCreditNoteDetail($creditNoteDetail);
}
}
}
}
return $this;
}
/**
* @param Form $formValidate
* @param CreditNote $creditNote
* @return $this
*/
protected function performOrderProducts(Form $formValidate, CreditNote $creditNote)
{
if (null === $creditNote->getOrder()) {
return $this;
}
/** @var string $freeAmountTypes */
$action = $formValidate->get('action')->getData();
/** @var int[] $orderProductQuantities */
$orderProductQuantities = $formValidate->get('order_product_quantity')->getData();
foreach ($creditNote->getOrder()->getOrderProducts() as $orderProduct) {
$creditNoteDetail = null;
if (null !== $creditNote->getId()) {
$creditNoteDetail = CreditNoteDetailQuery::create()
->filterByCreditNoteId($creditNote->getId())
->filterByOrderProductId($orderProduct->getId())
->findOne();
}
if (null === $creditNoteDetail) {
$creditNoteDetail = new CreditNoteDetail;
}
if ($creditNote->getCreditNoteType()->getCode() === CreditNoteHelper::TYPE_ORDER_FULL_REFUND) {
$creditNoteDetail->setQuantity($orderProduct->getQuantity());
} else {
if (isset($orderProductQuantities[$orderProduct->getId()])) {
$creditNoteDetail->setQuantity($orderProductQuantities[$orderProduct->getId()]);
}
}
if ((float) $creditNoteDetail->getQuantity() <= 0) {
$creditNote->removeCreditNoteDetail($creditNoteDetail);
continue;
}
if ((int) $orderProduct->getWasInPromo()) {
$orderProductWithoutTax = ((float) $orderProduct->getPromoPrice());
$orderProductWithTax = (float) $orderProduct->getPromoPrice();
} else {
$orderProductWithoutTax = ((float) $orderProduct->getPrice());
$orderProductWithTax = (float) $orderProduct->getPrice();
}
$orderProductTaxes = $orderProduct->getOrderProductTaxes();
/** @var OrderProductTax $orderProductTax */
foreach ($orderProductTaxes as $orderProductTax) {
if ((int) $orderProduct->getWasInPromo()) {
$orderProductWithTax += (float) $orderProductTax->getPromoAmount();
} else {
$orderProductWithTax += (float) $orderProductTax->getAmount();
}
}
$creditNoteDetail
->setOrderProduct($orderProduct)
->setTitle($orderProduct->getTitle())
->setPrice($orderProductWithoutTax)
->setType('product')
->setPriceWithTax($orderProductWithTax);
if (null !== $pse = ProductSaleElementsQuery::create()->findOneById($orderProduct->getProductSaleElementsId())) {
if ($pse->getProduct() === null) {
$creditNoteDetail->setTaxRuleId(TaxRuleQuery::create()->findOneByIsDefault(true)->getId());
} else {
$creditNoteDetail
->setTaxRuleId(
$pse
->getProduct()
->getTaxRuleId()
)
;
}
}
$creditNote->addCreditNoteDetail(
$creditNoteDetail
);
}
if ($action === 'update') {
foreach ($creditNote->getCreditNoteDetails() as $creditNoteDetail) {
if ((float) $creditNoteDetail->getQuantity() === 0.0 && $creditNoteDetail->getType() === 'product') {
$creditNote->removeCreditNoteDetail($creditNoteDetail);
}
}
}
return $this;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \Propel\Runtime\Exception\PropelException
*/
public function searchCustomerAction(Request $request)
{
$customerQuery = CustomerQuery::create()
->innerJoinAddress()
->groupById()
->limit(20);
$this->whereConcatRegex($customerQuery, [
'customer.FIRSTNAME',
'customer.LASTNAME',
'customer.EMAIL',
'address.COMPANY',
'address.PHONE'
], $request->get('q'));
$customerQuery
->withColumn(AddressTableMap::COMPANY, 'COMPANY')
->withColumn(AddressTableMap::ADDRESS1, 'ADDRESS')
->withColumn(AddressTableMap::CITY, 'CITY')
->withColumn(AddressTableMap::ZIPCODE, 'ZIPCODE')
->withColumn(AddressTableMap::PHONE, 'PHONE');
$customers = $customerQuery->find();
$json = [
'incomplete_results' => count($customers) ? false : true,
'items' => []
];
/** @var Customer $customer */
foreach ($customers as $customer) {
$json['items'][] = [
'id' => $customer->getId(),
'company' => $customer->getVirtualColumn('COMPANY'),
'firstname' => $customer->getFirstname(),
'lastname' => $customer->getLastname(),
'ref' => $customer->getRef(),
'address' => $this->formatAddress($customer)
];
}
return new JsonResponse($json);
}
/**
* @param Request $request
* @return JsonResponse
* @throws \Propel\Runtime\Exception\PropelException
*/
public function searchOrderAction(Request $request)
{
$orderQuery = OrderQuery::create();
//$orderQuery->filterByInvoiceRef(null, Criteria::ISNOTNULL);
$orderQuery->useOrderStatusQuery()
->filterById([1,5], Criteria::NOT_IN)
->endUse();
if (null !== $customerId = $request->get('customerId')) {
if ((int) $customerId > 0) {
$orderQuery->filterByCustomerId((int) $customerId);
}
}
$orderQuery->innerJoinOrderAddressRelatedByInvoiceOrderAddressId()
->groupById()
->limit(20);
$this->whereConcatRegex($orderQuery, [
'order.REF',
'order_address.LASTNAME',
'order_address.FIRSTNAME',
'order_address.COMPANY',
'order_address.PHONE'
], $request->get('q'));
$orderQuery
->withColumn(OrderAddressTableMap::FIRSTNAME, 'FIRSTNAME')
->withColumn(OrderAddressTableMap::LASTNAME, 'LASTNAME')
->withColumn(OrderAddressTableMap::COMPANY, 'COMPANY')
->withColumn(OrderAddressTableMap::ADDRESS1, 'ADDRESS')
->withColumn(OrderAddressTableMap::CITY, 'CITY')
->withColumn(OrderAddressTableMap::ZIPCODE, 'ZIPCODE')
->withColumn(OrderAddressTableMap::PHONE, 'PHONE');
$orders = $orderQuery->find();
$json = [
'incomplete_results' => count($orders) ? false : true,
'items' => []
];
/** @var Order $order */
foreach ($orders as $order) {
$json['items'][] = [
'id' => $order->getId(),
'ref' => $order->getRef(),
'company' => $order->getVirtualColumn('COMPANY'),
'firstname' => $order->getVirtualColumn('FIRSTNAME'),
'lastname' => $order->getVirtualColumn('LASTNAME'),
'address' => $this->formatAddress($order),
];
}
return new JsonResponse($json);
}
/**
* @param ActiveRecordInterface $model
* @return mixed
*/
protected function formatAddress(ActiveRecordInterface $model)
{
/** @var Order|Customer $model */
return implode(' ', [$model->getVirtualColumn('ADDRESS'), $model->getVirtualColumn('ZIPCODE'), $model->getVirtualColumn('CITY')]);
}
}

View File

@@ -0,0 +1,84 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote;
use Propel\Runtime\Connection\ConnectionInterface;
use Symfony\Component\Finder\Finder;
use Thelia\Model\ModuleQuery;
use Thelia\Module\BaseModule;
use Thelia\Install\Database;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class CreditNote extends BaseModule
{
const DOMAIN_MESSAGE = "creditnote";
const CONFIG_KEY_REF_PREFIX = 'ref_prefix';
const CONFIG_KEY_REF_MIN_LENGTH = 'ref_min_length';
const CONFIG_KEY_REF_INCREMENT = 'ref_increment';
const CONFIG_KEY_INVOICE_REF_PREFIX = 'invoice_ref_prefix';
const CONFIG_KEY_INVOICE_REF_MIN_LENGTH = 'invoice_ref_min_length';
const CONFIG_KEY_INVOICE_REF_INCREMENT = 'invoice_ref_increment';
const CONFIG_KEY_INVOICE_REF_WITH_THELIA_ORDER = 'invoice_ref_with_thelia_order';
/**
* @param ConnectionInterface $con
*/
public function postActivation(ConnectionInterface $con = null)
{
if (!$this->getConfigValue('is_initialized', false)) {
$database = new Database($con);
$database->insertSql(null, [__DIR__ . "/Config/thelia.sql", __DIR__ . "/Config/insert.sql"]);
$this->setConfigValue(self::CONFIG_KEY_REF_INCREMENT, 1);
$this->setConfigValue(self::CONFIG_KEY_REF_PREFIX, 'CN');
$this->setConfigValue(self::CONFIG_KEY_REF_MIN_LENGTH, 8);
$this->setConfigValue(self::CONFIG_KEY_INVOICE_REF_INCREMENT, 1);
$this->setConfigValue(self::CONFIG_KEY_INVOICE_REF_PREFIX, 'FA');
$this->setConfigValue(self::CONFIG_KEY_INVOICE_REF_MIN_LENGTH, 8);
$this->setConfigValue(self::CONFIG_KEY_INVOICE_REF_WITH_THELIA_ORDER, 0);
$this->setConfigValue('is_initialized', true);
}
}
public function update($currentVersion, $newVersion, ConnectionInterface $con = null)
{
if (null === self::getConfigValue(self::CONFIG_KEY_INVOICE_REF_WITH_THELIA_ORDER)) {
self::setConfigValue(
self::CONFIG_KEY_INVOICE_REF_WITH_THELIA_ORDER,
0
);
}
$sqlToExecute = [];
$finder = new Finder();
$sort = function (\SplFileInfo $a, \SplFileInfo $b) {
$a = strtolower(substr($a->getRelativePathname(), 0, -4));
$b = strtolower(substr($b->getRelativePathname(), 0, -4));
return version_compare($a, $b);
};
$files = $finder->name('*.sql')
->in(__DIR__ ."/Config/Update/")
->sort($sort);
foreach ($files as $file) {
if (version_compare($file->getFilename(), $currentVersion, ">")) {
$sqlToExecute[$file->getFilename()] = $file->getRealPath();
}
}
$database = new Database($con);
foreach ($sqlToExecute as $version => $sql) {
$database->insertSql(null, [$sql]);
}
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Event;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class CreditNoteEvents
{
const PROPEL_PRE_INSERT = "credit-note.pre.insert.";
const PROPEL_POST_INSERT = "credit-note.post.insert.";
const PROPEL_PRE_UPDATE = "credit-note.pre.update.";
const PROPEL_POST_UPDATE = "credit-note.post.update.";
const PROPEL_PRE_DELETE = "credit-note.pre.delete.";
const PROPEL_POST_DELETE = "credit-note.post.delete.";
public static function preInsert($tableName)
{
return self::PROPEL_PRE_INSERT . $tableName;
}
public static function postInsert($tableName)
{
return self::PROPEL_POST_INSERT . $tableName;
}
public static function preUpdate($tableName)
{
return self::PROPEL_PRE_UPDATE . $tableName;
}
public static function postUpdate($tableName)
{
return self::PROPEL_POST_UPDATE . $tableName;
}
public static function preDelete($tableName)
{
return self::PROPEL_PRE_DELETE . $tableName;
}
public static function postDelete($tableName)
{
return self::PROPEL_POST_DELETE . $tableName;
}
}

View File

@@ -0,0 +1,51 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Event;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Thelia\Core\Event\ActionEvent;
/**
* @author Gilles Bourgeat <gilles@thelia.fr>
*/
class PropelEvent extends ActionEvent
{
/** @var ActiveRecordInterface */
protected $instance;
/** @var mixed */
protected $return;
/**
* PropelEvent constructor.
* @param ActiveRecordInterface $instance
*/
public function __construct(ActiveRecordInterface $instance)
{
$this->instance = $instance;
}
/**
* @return ActiveRecordInterface
*/
public function getInstance()
{
return $this->instance;
}
/**
* @param ActiveRecordInterface $instance
* @return PropelEvent
*/
public function setInstance($instance)
{
$this->instance = $instance;
return $this;
}
}

View File

@@ -0,0 +1,123 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\EventListener;
use CreditNote\CreditNote;
use CreditNote\Event\CreditNoteEvents;
use CreditNote\Event\PropelEvent;
use CreditNote\Model\CreditNote as CreditNoteModel;
use CreditNote\Model\Map\CreditNoteTableMap;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Model\ConfigQuery;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*/
class CreditNoteListener implements EventSubscriberInterface
{
/**
* Add credit note ref before save
* @param PropelEvent $event
*/
public function generateCreditNoteInvoiceRef(PropelEvent $event)
{
/** @var CreditNoteModel $instance */
$instance = $event->getInstance();
if ($instance->isColumnModified(CreditNoteTableMap::STATUS_ID)) {
if ($instance->getInvoiceRef() !== null && !$instance->getCreditNoteStatus()->getInvoiced()) {
throw new \Exception('This credit note is already invoiced, you can not cancel it');
}
if ($instance->getCreditNoteStatus()->getInvoiced() && $instance->getInvoiceRef() === null) {
if ((int) CreditNote::getConfigValue(CreditNote::CONFIG_KEY_INVOICE_REF_WITH_THELIA_ORDER)) {
if (!class_exists('\InvoiceRef\EventListeners\OrderListener')) {
throw new \Exception('Missing module InvoiceRef');
}
// dans le cas ou la facturation suit celle des commandes
$invoiceRef = ConfigQuery::create()
->findOneByName('invoiceRef');
$value = $invoiceRef->getValue();
$instance->setInvoiceRef($value)
->setInvoiceDate(new \DateTime())
;
$invoiceRef->setValue(++$value)
->save();
} else {
// cas ou la facturation suit sa propre règle
$ref = CreditNote::getConfigValue(CreditNote::CONFIG_KEY_INVOICE_REF_PREFIX) . str_pad(
(int) CreditNote::getConfigValue(CreditNote::CONFIG_KEY_INVOICE_REF_INCREMENT, 1) + 1,
CreditNote::getConfigValue(CreditNote::CONFIG_KEY_INVOICE_REF_MIN_LENGTH, 8),
"0",
STR_PAD_LEFT
);
$instance->setInvoiceRef($ref);
$instance->setInvoiceDate(new \DateTime());
CreditNote::setConfigValue(
CreditNote::CONFIG_KEY_INVOICE_REF_INCREMENT,
(int) CreditNote::getConfigValue(CreditNote::CONFIG_KEY_INVOICE_REF_INCREMENT, 1) + 1
);
}
}
}
}
/**
* Add credit note ref before save
* @param PropelEvent $event
*/
public function generateCreditNoteRef(PropelEvent $event)
{
/** @var CreditNoteModel $instance */
$instance = $event->getInstance();
if ($instance->getRef() === null) {
$ref = CreditNote::getConfigValue(CreditNote::CONFIG_KEY_REF_PREFIX) . str_pad(
(int) CreditNote::getConfigValue(CreditNote::CONFIG_KEY_REF_INCREMENT, 1) + 1,
CreditNote::getConfigValue(CreditNote::CONFIG_KEY_REF_MIN_LENGTH, 8),
"0",
STR_PAD_LEFT
);
$instance->setRef($ref);
$instance->setInvoiceDate(new \DateTime());
}
$this->generateCreditNoteInvoiceRef($event);
}
public function incrementCreditNoteRef(PropelEvent $event)
{
CreditNote::setConfigValue(
CreditNote::CONFIG_KEY_REF_INCREMENT,
(int) CreditNote::getConfigValue(CreditNote::CONFIG_KEY_REF_INCREMENT, 1) + 1
);
}
public static function getSubscribedEvents()
{
return array(
CreditNoteEvents::preInsert(CreditNoteTableMap::TABLE_NAME) => [
'generateCreditNoteRef', 128
],
CreditNoteEvents::postInsert(CreditNoteTableMap::TABLE_NAME) => [
'incrementCreditNoteRef', 128
],
CreditNoteEvents::preUpdate(CreditNoteTableMap::TABLE_NAME) => [
'generateCreditNoteInvoiceRef', 128
]
);
}
}

View File

@@ -0,0 +1,156 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Form;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Thelia\Form\BaseForm;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*/
class CreditNoteCreateForm extends BaseForm
{
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return 'credit-note-create';
}
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->formBuilder attribute :
*
*/
protected function buildForm()
{
$this->formBuilder
->add('action', 'text', array(
'required' => false
))
->add('customer_id', 'integer', array(
'required' => false
))
->add('order_id', 'integer', array(
'required' => false
))
->add('status_id', 'integer', array(
'required' => false
))
->add('currency_id', 'integer', array(
'required' => false
))
->add('type_id', 'integer', array(
'required' => false
))
->add('currency_id', 'integer', array(
'required' => false
))
->add('total_price', 'number', array(
'required' => false
))
->add('comment', 'text', array(
'required' => false
));
$this->formBuilder
->add('order_product_quantity', 'collection', array(
'required' => false,
'allow_add' => true,
'allow_delete' => true
));
$this->formBuilder
->add('free_amount_price', 'collection', array(
'required' => false,
'allow_add' => true,
'allow_delete' => true
))
->add('free_amount_price_with_tax', 'collection', array(
'required' => false,
'allow_add' => true,
'allow_delete' => true
))
->add('free_amount_tax_rule_id', 'collection', array(
'required' => false,
'allow_add' => true,
'allow_delete' => true
))
->add('free_amount_type', 'collection', array(
'required' => false,
'allow_add' => true,
'allow_delete' => true
))
->add('free_amount_title', 'collection', array(
'required' => false,
'allow_add' => true,
'allow_delete' => true
))
->add('free_amount_id', 'collection', array(
'required' => false,
'allow_add' => true,
'allow_delete' => true
));
$this->formBuilder
->add('discount_without_tax', 'number', array(
'required' => false
))
->add('discount_with_tax', 'number', array(
'required' => false
))
;
$this->formBuilder->add('ui_target', ChoiceType::class, [
'choices' => [
'order' => 'order',
'customer' => 'customer'
]
]);
$this->formBuilder->add('ui_target_id', IntegerType::class);
$this->formBuilder
->add('invoice_address_id', IntegerType::class, array(
'required' => false
))
->add('invoice_address_title', TextType::class, array(
'required' => false
))
->add('invoice_address_firstname', TextType::class, array(
'required' => false
))
->add('invoice_address_lastname', TextType::class, array(
'required' => false
))
->add('invoice_address_company', TextType::class, array(
'required' => false
))
->add('invoice_address_address1', TextType::class, array(
'required' => false
))
->add('invoice_address_address2', TextType::class, array(
'required' => false
))
->add('invoice_address_zipcode', TextType::class, array(
'required' => false
))
->add('invoice_address_city', TextType::class, array(
'required' => false
))
->add('invoice_address_country_id', IntegerType::class, array(
'required' => false
))
;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Form;
use Thelia\Form\BaseForm;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*/
class CreditNoteEmptyForm extends BaseForm
{
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return 'credit-note-delete';
}
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->formBuilder attribute :
*
*/
protected function buildForm()
{
}
}

View File

@@ -0,0 +1,26 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class CreditNoteHelper
{
const STATUS_PROPOSED = 'proposed';
const STATUS_REFUSED = 'refused';
const STATUS_ACCEPTED = 'accepted';
const STATUS_USED = 'used';
const TYPE_ORDER_FULL_REFUND = 'order_full_refund';
const TYPE_BACK_PRODUCT = 'back_product';
const TYPE_BILLING_ERROR = 'billing_error';
const TYPE_REBATE = 'rebate';
const TYPE_DISCOUNT = 'discount';
}

View File

@@ -0,0 +1,57 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Helper;
use Propel\Runtime\ActiveQuery\ModelCriteria;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
trait CriteriaSearchHelper
{
/**
* @param string $q
* @return string
*/
public function getRegex($q)
{
$q = explode(' ', $q);
$words = array();
foreach ($q as $v) {
$v = trim($v);
if (strlen($v) > 2 && preg_match('/^[a-z0-9]+$/i', $v)) {
$words[] = $v;
}
}
if (!count($words)) {
return null;
}
$regex = array();
$regex[] = '.*' . implode('.+', $words) . '.*';
if (count($words) > 1) {
$regex[] = '.*' . implode('.+', array_reverse($words)) . '.*';
}
return implode('|', $regex);
}
/**
* @param ModelCriteria $query
* @param array $columns
* @param string $q
*/
public function whereConcatRegex(ModelCriteria $query, array $columns, $q)
{
$query->where("CONCAT_WS(' ', " . implode(',', $columns). ") REGEXP ?", self::getRegex($q), \PDO::PARAM_STR);
}
}

View File

@@ -0,0 +1,46 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Hook\Back;
use CreditNote\CreditNote;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
use Thelia\Core\Thelia;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class CustomerEditHook extends BaseHook
{
public function onCustomerEdit(HookRenderEvent $event)
{
$event->add($this->render(
'hook/customer.edit.html',
array_merge($event->getArguments(), [
])
));
}
public function onCustomerEditBottom(HookRenderEvent $event)
{
$event->add($this->render(
'includes/credit-note-modal.html',
array_merge($event->getArguments(), [])
));
}
public function onCustomerEditJs(HookRenderEvent $event)
{
$event->add($this->render(
'includes/credit-note-js.html',
array_merge($event->getArguments(), [])
));
}
}

View File

@@ -0,0 +1,29 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Hook\Back;
use CreditNote\CreditNote;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class MainHook extends BaseHook
{
public function onMainFooterJs(HookRenderEvent $event)
{
$event->add($this->render(
'hook/main.footer-js.html',
$event->getArguments() + [
'admin_current_location' => ($this->getRequest()->get('_route') == 'creditnote.list' ? 'credit-note' : '')
]
));
}
}

View File

@@ -0,0 +1,73 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Hook\Back;
use CreditNote\CreditNote;
use CreditNote\Model\CreditNoteDetailQuery;
use CreditNote\Model\CreditNoteQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Event\Hook\HookRenderBlockEvent;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
use Thelia\Core\Thelia;
use Thelia\Core\Translation\Translator;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class OrderEditHook extends BaseHook
{
public function onOrderEditProductList(HookRenderEvent $event)
{
$creditNoteDetails = CreditNoteDetailQuery::create()
->filterByQuantity(0, Criteria::GREATER_THAN)
->filterByOrderProductId($event->getArgument('order_product_id'))
->find();
$event->add($this->render(
'hook/order-edit.product-list.html',
$event->getArguments() + ['creditNoteDetails' => $creditNoteDetails]
));
}
public function onOrderTab(HookRenderBlockEvent $event)
{
$count = CreditNoteQuery::create()
->filterByOrderId($event->getArgument('id'))
->count();
$event->add(
[
"id" => "credit-note",
"title" => Translator::getInstance()->trans("Credit Note", [], CreditNote::DOMAIN_MESSAGE) . ($count ? ' (' . $count . ')' : ''),
"content" => $this->render('hook/order.tab.html', array_merge($event->getArguments(), [
]))
]
);
}
public function onOrderEditBottom(HookRenderEvent $event)
{
$event->add($this->render(
'includes/credit-note-modal.html',
array_merge($event->getArguments(), [
])
));
}
public function onOrderEditJs(HookRenderEvent $event)
{
$event->add($this->render(
'hook/order.edit-js.html',
array_merge($event->getArguments(), [])
));
}
}

View File

@@ -0,0 +1,15 @@
<?php
return [
"Credit notes" => "Credit notes",
"There are no credit notes for this order." => "There are no credit notes for this order.",
"Credit note for order %order_ref" => "Credit note for order %order_ref",
"Create a credit note" => "Create a credit note",
"Credit note created." => "Credit note created.",
"Credit note for this order" => "Credit note for this order",
"Total credit notes amount" => "Total credit notes amount",
"This order has not been paid." => "This order has not been paid.",
// emails
"Message sent to the customer when a credit note is created from an order."
=> "Message sent to the customer when a credit note is created from an order.",
];

View File

@@ -0,0 +1,107 @@
<?php
return array(
'#' => '#',
'Action' => 'Action',
'Add a free amount' => 'Ajouter un montant libre',
'Add a new credit note' => 'Ajouter un nouvel avoir',
'Address : ' => 'Adresse :',
'Address complement : ' => 'Complément d\'adresse :',
'All Credit Notes' => 'Tous les avoirs',
'Amount with tax' => 'Montant TTC',
'Amount with tax %currency' => 'Montant TTC %currency',
'Amount without tax' => 'Montant HT',
'Amount without tax %currency' => 'Montant HT %currency',
'An error has occurred !!!' => 'Une erreur est survenue',
'Cancel' => 'Annuler',
'City : ' => 'Ville :',
'Close' => 'Fermer',
'Combination reference' => 'Référence déclinaison',
'Company : ' => 'Société :',
'Country : ' => 'Pays :',
'Coupon code' => 'Code coupon',
'Create credit note' => 'Créer l\'avoir',
'Create date' => 'Date de création',
'Credit Note Informations : ' => 'Informations avoir',
'Credit Note ref' => 'Avoir ref',
'Credit Note used :' => 'Avoir utilisé',
'Credit Notes' => 'Avoirs',
'Credit note' => 'Avoir',
'Credit note ref : <strong>%ref</strong>' => 'Référence avoir : <strong>%ref</strong>',
'Credit note used : ' => 'Avoir utilisé :',
'Credit note versions : ' => 'Versions de l\'avoir',
'Credit notes' => 'Avoirs',
'Customer' => 'Client',
'Customer : ' => 'Client :',
'Delete' => 'Supprimer',
'Delete credit note' => 'Supprimer cet avoir',
'Discount' => 'Réduction',
'Discount with tax : ' => 'Réduction TTC',
'Discount without tax : ' => 'Réduction HT',
'Do you really want to delete this credit note ?' => 'Voulez-vous vraiment supprimer cet avoir',
'Edit' => 'Editer',
'Fees' => 'Honoraires',
'Firstname' => 'Prénom :',
'Free amount : ' => 'Montant libre',
'Home' => 'Accueil',
'Internal comment : ' => 'Commentaire interne',
'Invoice address' => 'Adresse de facturation',
'Invoice date' => 'Date facture',
'Invoice ref' => 'Référence facture',
'Invoice ref : <strong>%ref</strong>' => 'Référence facture : <strong>%ref</strong>',
'Lastname : ' => 'Nom :',
'Message content : ' => 'Message :',
'Message status : ' => 'Statut :',
'No' => 'Non',
'No comments found for this credit note' => 'Aucun commentaire trouvé pour cet avoir',
'No free amount.' => 'Aucun montant libre',
'No version found for this credit note' => 'Aucune version trouvée pour cet avoir',
'Order' => 'Commande',
'Order : ' => 'Commande :',
'Order Informations : ' => 'Informations sur la commande :',
'Order discount informations : ' => 'Information sur la réduction appliquée à la commande',
'Other' => 'Autre',
'PDF' => 'PDF',
'Please wait, loading' => 'Veillez patienter, chargement ...',
'Postage' => 'Frais de livraison',
'Product' => 'Produit',
'Quantity' => 'Quantité',
'Ref' => 'Ref',
'Ref :' => 'Ref :',
'Remaining to pay : ' => 'Reste à payer',
'Save' => 'Sauvgarder',
'Search...' => 'Rechercher ...',
'Shipping' => 'Livraison',
'Status' => 'Statut',
'Status : ' => 'Statut :',
'Status : %title' => 'Statut : %title',
'Tax' => 'Taxe',
'Tax rule' => 'Règle de taxe',
'Taxes' => 'Taxes',
'Taxes : ' => 'Taxes : ',
'This credit note use the currency : %currency' => 'Cet avoir utilise la devise : %currency',
'This credit note use the currency : <strong>%currency</strong>' => 'Cet avoir utilise la devise : <strong>%currency</strong>',
'Titile' => 'Titre',
'Title' => 'Titre',
'Total' => 'Total',
'Total including discount' => 'Total avec réduction',
'Total with tax' => 'Total TTC',
'Total with tax : ' => 'Total TTC : ',
'Total without discount' => 'Total sans réduction',
'Total without tax' => 'Total HT',
'Total without tax : ' => 'Total HT : ',
'Type' => 'Type',
'Type : ' => 'Type :',
'Unit taxed price' => 'Prix unitaire taxé',
'Unit. price' => 'Prix unitaire',
'Update credit note' => 'Mettre à jour l\'avoir',
'Update date' => 'Date de mise à jour',
'Used by order :' => 'Utilisé par commande :',
'User' => 'Utilisateur',
'View' => 'Voir',
'Virtual product' => 'Produit virtuel',
'Yes' => 'Oui',
'You can not create a credit note for this order because it is not invoiced.' => 'Vous ne pouvez pas créer d\'avoir pour cette commande, elle n\'est pas facturée',
'You have no credit notes for the moment.' => 'Vous n\'avez pas d\'avoir',
'Zipcode : ' => 'Code postal',
);

View File

@@ -0,0 +1,9 @@
<?php
return [
"Credit note on your order %order_ref"
=> "Credit note on your order %order_ref",
"You have been granted a credit note of %credit_note_amount on your order %order_ref."
=> "You have been granted a credit note of %credit_note_amount on your order %order_ref.",
"Use the coupon code %coupon_code to use this credit note."
=> "Use the coupon code %coupon_code to use this credit note.",
];

View File

@@ -0,0 +1,9 @@
<?php
return [
"Credit note on your order %order_ref"
=> "Avoir sur votre commande %order_ref",
"You have been granted a credit note of %credit_note_amount on your order %order_ref."
=> "Un avoir de %credit_note_amount vous a été accordé suite à votre commande %order_ref.",
"Use the coupon code %coupon_code to use this credit note."
=> "Utilisez-le en entrant le code promo %coupon_code.",
];

View File

@@ -0,0 +1,10 @@
<?php
return [
// configuration
"CreditNote module configuration" => "CreditNote module configuration",
"Configuration correctly saved" => "Configuration correctly saved",
"Coupon code validity period (days)" => "Coupon code validity period (days)",
"Coupon code prefix" => "Coupon code prefix",
"Restrict coupon codes from order credit notes to the original customer"
=> "Restrict coupon codes from order credit notes to the original customer",
];

View File

@@ -0,0 +1,7 @@
<?php
return array(
'Credit Note' => 'Avoir',
'We\'re sorry, this PDF invoice is not available at the moment.' => 'Erreur, impossible de créer le pdf',
'You can not delete this credit note' => 'Vous ne pouvez pas supprimer cet avoir',
);

View File

@@ -0,0 +1,25 @@
<?php
return array(
'CREDIT NOTE INVOICE' => 'Facture d\'avoir',
'Combination ref : ' => 'Référence déclinaison :',
'Credit note REF' => 'Référence avoir',
'Customer Number' => 'Référence client',
'Discount' => 'Réduction',
'Email: ' => 'E-mail :',
'Invoice REF' => 'Référence facture',
'Invoice address' => 'Adresse de facturation',
'Invoice date' => 'Date de facturation',
'Phone: ' => 'Téléphone :',
'Product' => 'Produit',
'Product ref : ' => 'Référence produit :',
'Quantity' => 'Quantité',
'Referance invoice REF' => 'Fait référence à la facture',
'Referance order REF' => 'Fait référence à la commande',
'Tax' => 'Taxe',
'Total with tax' => 'Total TTC',
'Total without tax' => 'Total HT',
'Unit taxed price' => 'Prix unitaire taxé',
'Unit. price' => 'Prix unitaire',
'page' => 'page',
);

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 thelia-modules
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,270 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Loop;
use CreditNote\Model\CreditNoteQuery;
use CreditNote\Model\CreditNote as CreditNoteModel;
use CreditNote\Model\Map\CreditNoteStatusI18nTableMap;
use CreditNote\Model\Map\CreditNoteStatusTableMap;
use CreditNote\Model\Map\CreditNoteTypeI18nTableMap;
use CreditNote\Model\Map\CreditNoteTypeTableMap;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\Map\CustomerTableMap;
use Thelia\Model\Map\OrderTableMap;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*
* @method string[] getRef()
* @method string[] getInvoiceRef()
* @method int[] getId()
* @method int[] getStatusId()
* @method int[] getOrderProductId()
* @method int[] getTypeId()
* @method int[] getOrderId()
* @method int[] getCustomerId()
* @method int[] getParentId()
* @method string[] getOrder()
* @method boolean|string getUsed()
* @method boolean|string getInvoiced()
*/
class CreditNote extends BaseLoop implements PropelSearchLoopInterface
{
protected $timestampable = true;
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createAnyListTypeArgument('ref'),
Argument::createAnyListTypeArgument('invoice_ref'),
Argument::createIntListTypeArgument("id"),
Argument::createAnyListTypeArgument("status_id"),
Argument::createAnyListTypeArgument("order_product_id"),
Argument::createAnyListTypeArgument("type_id"),
Argument::createIntListTypeArgument("order_id"),
Argument::createIntListTypeArgument("customer_id"),
Argument::createIntListTypeArgument("parent_id"),
Argument::createBooleanOrBothTypeArgument("used"),
Argument::createBooleanOrBothTypeArgument("invoiced"),
Argument::createEnumListTypeArgument(
"order",
[
"id", "id-reverse",
"create-date", "create-date-reverse",
"status", "status-reverse",
'update-date', 'update-date-reverse',
],
"id"
)
);
}
/**
* this method returns a Propel ModelCriteria
*
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
$query = new CreditNoteQuery();
if (null !== $id = $this->getId()) {
$query->filterById($id);
}
if (null !== $invoiceRef = $this->getInvoiceRef()) {
$query->filterByInvoiceRef($invoiceRef);
}
if (null !== $ref = $this->getRef()) {
$query->filterByRef($ref);
}
if (null !== $type = $this->getTypeId()) {
$query->FilterByTypeId($type);
}
if (null !== $status = $this->getStatusId()) {
$query->filterByStatusId($status);
}
if (null !== $orderProduct = $this->getOrderProductId()) {
$query->useCreditNoteDetailQuery()
->filterByOrderProductId($orderProduct)
->endUse();
}
if (null !== $order = $this->getOrderId()) {
$query->filterByOrderId($order);
}
if (null !== $parent = $this->getParentId()) {
$query->filterByParentId($parent);
}
if (null !== $customer = $this->getCustomerId()) {
$query->filterByCustomerId($customer);
}
if (is_bool($this->getUsed())) {
$query->useCreditNoteStatusQuery()
->filterByUsed($this->getUsed())
->endUse();
}
if (is_bool($this->getInvoiced())) {
$query->useCreditNoteStatusQuery()
->filterByInvoiced($this->getInvoiced())
->endUse();
}
$this->addJoin($query);
$this->addVirtualColumn($query);
$this->buildModelCriteriaOrder($query);
$query->groupById();
return $query;
}
/**
* @param CreditNoteQuery $query
*/
protected function buildModelCriteriaOrder($query)
{
foreach ($this->getOrder() as $order) {
switch ($order) {
case "id":
$query->orderById();
break;
case "id-reverse":
$query->orderById(Criteria::DESC);
break;
case 'create-date':
$query->orderByCreatedAt(Criteria::ASC);
break;
case 'create-date-reverse':
$query->orderByCreatedAt(Criteria::DESC);
break;
case 'status':
$query->orderByStatusId(Criteria::ASC);
break;
case 'status-reverse':
$query->orderByStatusId(Criteria::DESC);
break;
case 'update-date':
$query->orderByUpdatedAt(Criteria::ASC);
break;
case 'update-date-reverse':
$query->orderByUpdatedAt(Criteria::DESC);
break;
}
}
}
/**
* @param CreditNoteQuery $query
*/
protected function addJoin($query)
{
$query->useCustomerQuery()
->endUse();
$query->useOrderQuery()
->endUse();
$query->useCreditNoteTypeQuery()
->leftJoinCreditNoteTypeI18n(CreditNoteTypeI18nTableMap::TABLE_NAME)
->endUse();
$query->addJoinCondition(CreditNoteTypeI18nTableMap::TABLE_NAME, CreditNoteTypeI18nTableMap::LOCALE . '=?', $this->getLocale());
$query->useCreditNoteStatusQuery()
->leftJoinCreditNoteStatusI18n(CreditNoteStatusI18nTableMap::TABLE_NAME)
->endUse();
$query->addJoinCondition(CreditNoteStatusI18nTableMap::TABLE_NAME, CreditNoteStatusI18nTableMap::LOCALE . '=?', $this->getLocale());
}
/**
* @param CreditNoteQuery $query
*/
protected function addVirtualColumn($query)
{
$query
->withColumn('CONCAT_WS(" ",' . CustomerTableMap::FIRSTNAME . ',' . CustomerTableMap::LASTNAME .')', 'CUSTOMER_NAME')
->withColumn(OrderTableMap::REF, 'ORDER_REF')
->withColumn(CreditNoteStatusI18nTableMap::TITLE, 'STATUS_TITLE')
->withColumn(CreditNoteStatusTableMap::COLOR, 'STATUS_COLOR')
->withColumn(CreditNoteTypeI18nTableMap::TITLE, 'TYPE_TITLE')
->withColumn(CreditNoteTypeTableMap::COLOR, 'TYPE_COLOR');
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var CreditNoteModel $entry */
foreach ($loopResult->getResultDataCollection() as $entry) {
$row = new LoopResultRow($entry);
$row
->set("ID", $entry->getId())
->set("REF", $entry->getRef())
->set("INVOICE_REF", $entry->getInvoiceRef())
->set("INVOICE_DATE", $entry->getInvoiceDate())
->set("TYPE_ID", $entry->getTypeId())
->set("STATUS_ID", $entry->getStatusId())
->set("ORDER_ID", $entry->getOrderId())
->set("PARENT_ID", $entry->getParentId())
->set("CUSTOMER_ID", $entry->getCustomerId())
->set('CURRENCY_ID', $entry->getCurrencyId())
->set("TOTAL_PRICE", $entry->getTotalPrice())
->set("TOTAL_PRICE_WITH_TAX", $entry->getTotalPriceWithTax())
->set("DISCOUNT_WITHOUT_TAX", $entry->getDiscountWithoutTax())
->set("DISCOUNT_WITH_TAX", $entry->getDiscountWithTax())
->set('CUSTOMER_NAME', $entry->getVirtualColumn('CUSTOMER_NAME'))
->set('ORDER_REF', $entry->getVirtualColumn('ORDER_REF'))
->set('STATUS_TITLE', $entry->getVirtualColumn('STATUS_TITLE'))
->set('STATUS_COLOR', $entry->getVirtualColumn('STATUS_COLOR'))
->set('TYPE_TITLE', $entry->getVirtualColumn('TYPE_TITLE'))
->set('TYPE_COLOR', $entry->getVirtualColumn('TYPE_COLOR'))
;
$this->addOutputFields($row, $entry);
$loopResult->addRow($row);
}
return $loopResult;
}
/**
* @return string
*/
protected function getLocale()
{
if ($this->request->fromAdmin()) {
return $this->request->getSession()->getAdminUser()->getLocale();
} else {
return $this->request->getSession()->getLang()->getLocale();
}
}
}

View File

@@ -0,0 +1,76 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Loop;
use CreditNote\Model\CreditNoteAddressQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class CreditNoteAddress extends BaseLoop implements PropelSearchLoopInterface
{
protected $timestampable = true;
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('id', null, true)
);
}
public function buildModelCriteria()
{
$search = CreditNoteAddressQuery::create();
$id = $this->getId();
$search->filterById($id, Criteria::IN);
return $search;
}
public function parseResults(LoopResult $loopResult)
{
/** @var \CreditNote\Model\CreditNoteAddress $creditNoteAddress */
foreach ($loopResult->getResultDataCollection() as $creditNoteAddress) {
$loopResultRow = new LoopResultRow($creditNoteAddress);
$loopResultRow
->set("ID", $creditNoteAddress->getId())
->set("TITLE", $creditNoteAddress->getCustomerTitleId())
->set("COMPANY", $creditNoteAddress->getCompany())
->set("FIRSTNAME", $creditNoteAddress->getFirstname())
->set("LASTNAME", $creditNoteAddress->getLastname())
->set("ADDRESS1", $creditNoteAddress->getAddress1())
->set("ADDRESS2", $creditNoteAddress->getAddress2())
->set("ADDRESS3", $creditNoteAddress->getAddress3())
->set("ZIPCODE", $creditNoteAddress->getZipcode())
->set("CITY", $creditNoteAddress->getCity())
->set("COUNTRY", $creditNoteAddress->getCountryId())
->set("STATE", $creditNoteAddress->getStateId())
->set("PHONE", $creditNoteAddress->getPhone())
->set("CELLPHONE", $creditNoteAddress->getCellphone())
;
$this->addOutputFields($loopResultRow, $creditNoteAddress);
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -0,0 +1,126 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Loop;
use CreditNote\Model\CreditNoteCommentQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\Map\AdminTableMap;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*
* @method string[] getCode()
* @method int[] getId()
* @method int[] getCreditNoteId()
* @method string[] getOrder()
*/
class CreditNoteComment extends BaseI18nLoop implements PropelSearchLoopInterface
{
protected $timestampable = true;
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument("id"),
Argument::createIntListTypeArgument("credit_note_id"),
Argument::createEnumListTypeArgument(
"order",
[
"id", "id-reverse",
"create-date", "create-date-reverse"
],
"create-date"
)
);
}
/**
* this method returns a Propel ModelCriteria
*
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
$query = new CreditNoteCommentQuery();
if (null !== $id = $this->getId()) {
$query->filterById($id);
}
if (null !== $creditNoteId = $this->getCreditNoteId()) {
$query->filterByCreditNoteId($creditNoteId);
}
$query->useAdminQuery()
->endUse();
$query->withColumn(AdminTableMap::LOGIN, 'ADMIN_LOGIN');
$query->withColumn(AdminTableMap::FIRSTNAME, 'ADMIN_FIRST_NAME');
$query->withColumn(AdminTableMap::LASTNAME, 'ADMIN_LAST_NAME');
$this->buildModelCriteriaOrder($query);
return $query;
}
/**
* @param CreditNoteCommentQuery $query
*/
protected function buildModelCriteriaOrder($query)
{
foreach ($this->getOrder() as $order) {
switch ($order) {
case "id":
$query->orderById();
break;
case "id-reverse":
$query->orderById(Criteria::DESC);
break;
case 'create-date':
$query->orderByCreatedAt(Criteria::ASC);
break;
case 'create-date-reverse':
$query->orderByCreatedAt(Criteria::DESC);
break;
}
}
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var \CreditNote\Model\CreditNoteComment $entry */
foreach ($loopResult->getResultDataCollection() as $entry) {
$row = new LoopResultRow($entry);
$row
->set("ID", $entry->getId())
->set("CREDIT_NOTE_ID", $entry->getCreditNoteId())
->set("ADMIN_ID", $entry->getAdminId())
->set("ADMIN_LOGIN", $entry->getVirtualColumn('ADMIN_LOGIN'))
->set("ADMIN_FIRST_NAME", $entry->getVirtualColumn('ADMIN_FIRST_NAME'))
->set("ADMIN_LAST_NAME", $entry->getVirtualColumn('ADMIN_LAST_NAME'))
->set("COMMENT", $entry->getComment())
;
$this->addOutputFields($row, $entry);
$loopResult->addRow($row);
}
return $loopResult;
}
}

View File

@@ -0,0 +1,112 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Loop;
use CreditNote\Model\CreditNoteDetailQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*
* @method int[] getId()
* @method int[] getCreditNoteId()
* @method string[] getOrder()
*/
class CreditNoteDetail extends BaseI18nLoop implements PropelSearchLoopInterface
{
protected $timestampable = true;
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument("id"),
Argument::createIntListTypeArgument("credit_note_id"),
Argument::createEnumListTypeArgument(
"order",
[
"id", "id-reverse"
],
"id"
)
);
}
/**
* this method returns a Propel ModelCriteria
*
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
$query = new CreditNoteDetailQuery();
if (null !== $id = $this->getId()) {
$query->filterById($id);
}
if (null !== $creditNoteId = $this->getCreditNoteId()) {
$query->filterByCreditNoteId($creditNoteId);
}
$this->buildModelCriteriaOrder($query);
return $query;
}
/**
* @param CreditNoteDetailQuery $query
*/
protected function buildModelCriteriaOrder($query)
{
foreach ($this->getOrder() as $order) {
switch ($order) {
case "id":
$query->orderById();
break;
case "id-reverse":
$query->orderById(Criteria::DESC);
break;
}
}
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var \CreditNote\Model\CreditNoteDetail $entry */
foreach ($loopResult->getResultDataCollection() as $entry) {
$row = new LoopResultRow($entry);
$row
->set("ID", $entry->getId())
->set("CREDIT_NOTE_ID", $entry->getCreditNoteId())
->set("PRICE", $entry->getPrice())
->set("PRICE_WITH_TAX", $entry->getPriceWithTax())
->set("TAX_RULE_ID", $entry->getTaxRuleId())
->set("ORDER_PRODUCT_ID", $entry->getOrderProductId())
->set("TYPE", $entry->getType())
->set("QUANTITY", $entry->getQuantity())
->set("TITLE", $entry->getTitle())
;
$this->addOutputFields($row, $entry);
$loopResult->addRow($row);
}
return $loopResult;
}
}

View File

@@ -0,0 +1,168 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Loop;
use CreditNote\Model\CreditNoteStatusFlowQuery;
use CreditNote\Model\CreditNoteStatusQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Type\BooleanOrBothType;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*
* @method string[] getCode()
* @method int[] getId()
* @method int[] getPosition()
* @method int[] getCurrentStatusId()
* @method string[] getOrder()
* @method string|bool getInvoiced()
* @method string|bool getUsed()
*/
class CreditNoteStatus extends BaseI18nLoop implements PropelSearchLoopInterface
{
protected $timestampable = true;
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createAnyListTypeArgument('code'),
Argument::createIntListTypeArgument("id"),
Argument::createIntListTypeArgument("position"),
Argument::createBooleanOrBothTypeArgument("invoiced", BooleanOrBothType::ANY),
Argument::createBooleanOrBothTypeArgument("used", BooleanOrBothType::ANY),
Argument::createIntListTypeArgument("current_status_id"),
Argument::createEnumListTypeArgument(
"order",
[
"id", "id-reverse",
"create-date", "create-date-reverse",
"code", "code-reverse",
"position", "position-reverse"
],
"position"
)
);
}
/**
* this method returns a Propel ModelCriteria
*
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
$query = new CreditNoteStatusQuery();
if (null !== $id = $this->getId()) {
$query->filterById($id);
}
if (null !== $code = $this->getCode()) {
$query->filterByCode($code);
}
if (null !== $position = $this->getPosition()) {
$query->filterByPosition($position);
}
if (BooleanOrBothType::ANY !== $used = $this->getUsed()) {
$query->filterByUsed($used);
}
if (BooleanOrBothType::ANY !== $invoiced = $this->getInvoiced()) {
$query->filterByInvoiced($invoiced);
}
if (null !== $currentStatusId = $this->getCurrentStatusId()) {
$flowIds = CreditNoteStatusFlowQuery::create()
->filterByFromStatusId($currentStatusId)
->find()->toArray('toStatusId');
$flowIds = array_keys($flowIds);
$query->filterById(array_merge($flowIds, $currentStatusId));
}
$this->configureI18nProcessing($query, ['TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM']);
$this->buildModelCriteriaOrder($query);
$query->groupById();
return $query;
}
/**
* @param CreditNoteStatusQuery $query
*/
protected function buildModelCriteriaOrder($query)
{
foreach ($this->getOrder() as $order) {
switch ($order) {
case "id":
$query->orderById();
break;
case "id-reverse":
$query->orderById(Criteria::DESC);
break;
case 'create-date':
$query->orderByCreatedAt(Criteria::ASC);
break;
case 'create-date-reverse':
$query->orderByCreatedAt(Criteria::DESC);
break;
case 'code':
$query->orderByCode(Criteria::ASC);
break;
case 'code-reverse':
$query->orderByCode(Criteria::DESC);
break;
case 'position':
$query->orderByPosition(Criteria::ASC);
break;
case 'position-reverse':
$query->orderByPosition(Criteria::DESC);
break;
}
}
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var \CreditNote\Model\CreditNoteStatus $entry */
foreach ($loopResult->getResultDataCollection() as $entry) {
$row = new LoopResultRow($entry);
$row
->set("ID", $entry->getId())
->set("CODE", $entry->getCode())
->set("COLOR", $entry->getColor())
->set("POSITION", $entry->getPosition())
->set("TITLE", $entry->getVirtualColumn('i18n_TITLE'))
->set("CHAPO", $entry->getVirtualColumn('i18n_CHAPO'))
->set("DESCRIPTION", $entry->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM", $entry->getVirtualColumn('i18n_POSTSCRIPTUM'))
;
$this->addOutputFields($row, $entry);
$loopResult->addRow($row);
}
return $loopResult;
}
}

View File

@@ -0,0 +1,140 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Loop;
use CreditNote\Model\CreditNoteTypeQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*
* @method string[] getCode()
* @method int[] getId()
* @method int[] getPosition()
* @method string[] getOrder()
*/
class CreditNoteType extends BaseI18nLoop implements PropelSearchLoopInterface
{
protected $timestampable = true;
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createAnyListTypeArgument('code'),
Argument::createIntListTypeArgument("id"),
Argument::createIntListTypeArgument("position"),
Argument::createEnumListTypeArgument(
"order",
[
"id", "id-reverse",
"create-date", "create-date-reverse",
"code", "code-reverse",
"position", "position-reverse"
],
"position"
)
);
}
/**
* this method returns a Propel ModelCriteria
*
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
$query = new CreditNoteTypeQuery();
if (null !== $id = $this->getId()) {
$query->filterById($id);
}
if (null !== $code = $this->getCode()) {
$query->filterByCode($code);
}
if (null !== $position = $this->getPosition()) {
$query->filterByPosition($position);
}
$this->configureI18nProcessing($query, ['TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM']);
$this->buildModelCriteriaOrder($query);
return $query;
}
/**
* @param CreditNoteTypeQuery $query
*/
protected function buildModelCriteriaOrder($query)
{
foreach ($this->getOrder() as $order) {
switch ($order) {
case "id":
$query->orderById();
break;
case "id-reverse":
$query->orderById(Criteria::DESC);
break;
case 'create-date':
$query->orderByCreatedAt(Criteria::ASC);
break;
case 'create-date-reverse':
$query->orderByCreatedAt(Criteria::DESC);
break;
case 'code':
$query->orderByCode(Criteria::ASC);
break;
case 'code-reverse':
$query->orderByCode(Criteria::DESC);
break;
case 'position':
$query->orderByPosition(Criteria::ASC);
break;
case 'position-reverse':
$query->orderByPosition(Criteria::DESC);
break;
}
}
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var \CreditNote\Model\CreditNoteType $entry */
foreach ($loopResult->getResultDataCollection() as $entry) {
$row = new LoopResultRow($entry);
$row
->set("ID", $entry->getId())
->set("CODE", $entry->getCode())
->set("COLOR", $entry->getColor())
->set("POSITION", $entry->getPosition())
->set("TITLE", $entry->getVirtualColumn('i18n_TITLE'))
->set("CHAPO", $entry->getVirtualColumn('i18n_CHAPO'))
->set("DESCRIPTION", $entry->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM", $entry->getVirtualColumn('i18n_POSTSCRIPTUM'))
;
$this->addOutputFields($row, $entry);
$loopResult->addRow($row);
}
return $loopResult;
}
}

View File

@@ -0,0 +1,148 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Loop;
use CreditNote\Model\CreditNoteVersionQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*
* @method string[] getRef()
* @method int[] getId()
* @method string[] getOrder()
*/
class CreditNoteVersion extends BaseLoop implements PropelSearchLoopInterface
{
protected $timestampable = true;
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createAnyListTypeArgument('ref'),
Argument::createIntListTypeArgument("id"),
Argument::createEnumListTypeArgument(
"order",
[
"id", "id-reverse",
"create-date", "create-date-reverse"
],
"id"
)
);
}
/**
* this method returns a Propel ModelCriteria
*
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
$query = new CreditNoteVersionQuery();
if (null !== $id = $this->getId()) {
$query->filterById($id);
}
if (null !== $ref = $this->getRef()) {
$query->filterByRef($ref);
}
$this->addJoin($query);
$this->addVirtualColumn($query);
$this->buildModelCriteriaOrder($query);
$query->groupById();
return $query;
}
/**
* @param CreditNoteVersionQuery $query
*/
protected function buildModelCriteriaOrder($query)
{
foreach ($this->getOrder() as $order) {
switch ($order) {
case "id":
$query->orderById();
break;
case "id-reverse":
$query->orderById(Criteria::DESC);
break;
case 'create-date':
$query->orderByCreatedAt(Criteria::ASC);
break;
case 'create-date-reverse':
$query->orderByCreatedAt(Criteria::DESC);
break;
}
}
}
/**
* @param CreditNoteVersionQuery $query
*/
protected function addJoin($query)
{
}
/**
* @param CreditNoteVersionQuery $query
*/
protected function addVirtualColumn($query)
{
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var \CreditNote\Model\CreditNoteVersion $entry */
foreach ($loopResult->getResultDataCollection() as $entry) {
$row = new LoopResultRow($entry);
$row
->set("ID", $entry->getId())
->set("REF", $entry->getRef())
->set("TYPE_ID", $entry->getTypeId())
->set("STATUS_ID", $entry->getStatusId())
->set("ORDER_ID", $entry->getOrderId())
->set("PARENT_ID", $entry->getParentId())
->set("CUSTOMER_ID", $entry->getCustomerId())
->set("TOTAL_AMOUNT_PRICE", $entry->getTotalPriceWithTax())
;
$this->addOutputFields($row, $entry);
$loopResult->addRow($row);
}
return $loopResult;
}
/**
* @return string
*/
protected function getLocale()
{
return $this->request->getSession()->getAdminEditionLang()->getLocale();
}
}

View File

@@ -0,0 +1,78 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Loop;
use CreditNote\Model\OrderCreditNoteQuery;
use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
/**
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*
* @method int[] getCreditNoteId()
* @method int[] getOrderId()
*/
class OrderCreditNote extends BaseI18nLoop implements PropelSearchLoopInterface
{
protected $timestampable = true;
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument("credit_note_id"),
Argument::createIntListTypeArgument("order_id")
);
}
/**
* this method returns a Propel ModelCriteria
*
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
$query = new OrderCreditNoteQuery();
if (null !== $creditNoteId = $this->getCreditNoteId()) {
$query->filterByCreditNoteId($creditNoteId);
}
if (null !== $orderId = $this->getOrderId()) {
$query->filterByOrderId($orderId);
}
return $query;
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var \CreditNote\Model\OrderCreditNote $entry */
foreach ($loopResult->getResultDataCollection() as $entry) {
$row = new LoopResultRow($entry);
$row
->set("ORDER_ID", $entry->getOrderId())
->set("CREDIT_NOTE_ID", $entry->getCreditNoteId())
->set("AMOUNT", $entry->getAmountPrice())
;
$this->addOutputFields($row, $entry);
$loopResult->addRow($row);
}
return $loopResult;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,774 @@
<?php
namespace CreditNote\Model\Base;
use \Exception;
use \PDO;
use CreditNote\Model\CartCreditNote as ChildCartCreditNote;
use CreditNote\Model\CartCreditNoteQuery as ChildCartCreditNoteQuery;
use CreditNote\Model\Map\CartCreditNoteTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\Cart;
/**
* Base class that represents a query for the 'cart_credit_note' table.
*
*
*
* @method ChildCartCreditNoteQuery orderByCartId($order = Criteria::ASC) Order by the cart_id column
* @method ChildCartCreditNoteQuery orderByCreditNoteId($order = Criteria::ASC) Order by the credit_note_id column
* @method ChildCartCreditNoteQuery orderByAmountPrice($order = Criteria::ASC) Order by the amount_price column
* @method ChildCartCreditNoteQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCartCreditNoteQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildCartCreditNoteQuery groupByCartId() Group by the cart_id column
* @method ChildCartCreditNoteQuery groupByCreditNoteId() Group by the credit_note_id column
* @method ChildCartCreditNoteQuery groupByAmountPrice() Group by the amount_price column
* @method ChildCartCreditNoteQuery groupByCreatedAt() Group by the created_at column
* @method ChildCartCreditNoteQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildCartCreditNoteQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildCartCreditNoteQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildCartCreditNoteQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildCartCreditNoteQuery leftJoinCart($relationAlias = null) Adds a LEFT JOIN clause to the query using the Cart relation
* @method ChildCartCreditNoteQuery rightJoinCart($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Cart relation
* @method ChildCartCreditNoteQuery innerJoinCart($relationAlias = null) Adds a INNER JOIN clause to the query using the Cart relation
*
* @method ChildCartCreditNoteQuery leftJoinCreditNote($relationAlias = null) Adds a LEFT JOIN clause to the query using the CreditNote relation
* @method ChildCartCreditNoteQuery rightJoinCreditNote($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CreditNote relation
* @method ChildCartCreditNoteQuery innerJoinCreditNote($relationAlias = null) Adds a INNER JOIN clause to the query using the CreditNote relation
*
* @method ChildCartCreditNote findOne(ConnectionInterface $con = null) Return the first ChildCartCreditNote matching the query
* @method ChildCartCreditNote findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCartCreditNote matching the query, or a new ChildCartCreditNote object populated from the query conditions when no match is found
*
* @method ChildCartCreditNote findOneByCartId(int $cart_id) Return the first ChildCartCreditNote filtered by the cart_id column
* @method ChildCartCreditNote findOneByCreditNoteId(int $credit_note_id) Return the first ChildCartCreditNote filtered by the credit_note_id column
* @method ChildCartCreditNote findOneByAmountPrice(string $amount_price) Return the first ChildCartCreditNote filtered by the amount_price column
* @method ChildCartCreditNote findOneByCreatedAt(string $created_at) Return the first ChildCartCreditNote filtered by the created_at column
* @method ChildCartCreditNote findOneByUpdatedAt(string $updated_at) Return the first ChildCartCreditNote filtered by the updated_at column
*
* @method array findByCartId(int $cart_id) Return ChildCartCreditNote objects filtered by the cart_id column
* @method array findByCreditNoteId(int $credit_note_id) Return ChildCartCreditNote objects filtered by the credit_note_id column
* @method array findByAmountPrice(string $amount_price) Return ChildCartCreditNote objects filtered by the amount_price column
* @method array findByCreatedAt(string $created_at) Return ChildCartCreditNote objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCartCreditNote objects filtered by the updated_at column
*
*/
abstract class CartCreditNoteQuery extends ModelCriteria
{
/**
* Initializes internal state of \CreditNote\Model\Base\CartCreditNoteQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\CreditNote\\Model\\CartCreditNote', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildCartCreditNoteQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildCartCreditNoteQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \CreditNote\Model\CartCreditNoteQuery) {
return $criteria;
}
$query = new \CreditNote\Model\CartCreditNoteQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array[$cart_id, $credit_note_id] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildCartCreditNote|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = CartCreditNoteTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(CartCreditNoteTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCartCreditNote A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT CART_ID, CREDIT_NOTE_ID, AMOUNT_PRICE, CREATED_AT, UPDATED_AT FROM cart_credit_note WHERE CART_ID = :p0 AND CREDIT_NOTE_ID = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildCartCreditNote();
$obj->hydrate($row);
CartCreditNoteTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCartCreditNote|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
$this->addUsingAlias(CartCreditNoteTableMap::CART_ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $key[1], Criteria::EQUAL);
return $this;
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(CartCreditNoteTableMap::CART_ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(CartCreditNoteTableMap::CREDIT_NOTE_ID, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
}
/**
* Filter the query on the cart_id column
*
* Example usage:
* <code>
* $query->filterByCartId(1234); // WHERE cart_id = 1234
* $query->filterByCartId(array(12, 34)); // WHERE cart_id IN (12, 34)
* $query->filterByCartId(array('min' => 12)); // WHERE cart_id > 12
* </code>
*
* @see filterByCart()
*
* @param mixed $cartId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function filterByCartId($cartId = null, $comparison = null)
{
if (is_array($cartId)) {
$useMinMax = false;
if (isset($cartId['min'])) {
$this->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cartId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($cartId['max'])) {
$this->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cartId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cartId, $comparison);
}
/**
* Filter the query on the credit_note_id column
*
* Example usage:
* <code>
* $query->filterByCreditNoteId(1234); // WHERE credit_note_id = 1234
* $query->filterByCreditNoteId(array(12, 34)); // WHERE credit_note_id IN (12, 34)
* $query->filterByCreditNoteId(array('min' => 12)); // WHERE credit_note_id > 12
* </code>
*
* @see filterByCreditNote()
*
* @param mixed $creditNoteId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function filterByCreditNoteId($creditNoteId = null, $comparison = null)
{
if (is_array($creditNoteId)) {
$useMinMax = false;
if (isset($creditNoteId['min'])) {
$this->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($creditNoteId['max'])) {
$this->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId, $comparison);
}
/**
* Filter the query on the amount_price column
*
* Example usage:
* <code>
* $query->filterByAmountPrice(1234); // WHERE amount_price = 1234
* $query->filterByAmountPrice(array(12, 34)); // WHERE amount_price IN (12, 34)
* $query->filterByAmountPrice(array('min' => 12)); // WHERE amount_price > 12
* </code>
*
* @param mixed $amountPrice The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function filterByAmountPrice($amountPrice = null, $comparison = null)
{
if (is_array($amountPrice)) {
$useMinMax = false;
if (isset($amountPrice['min'])) {
$this->addUsingAlias(CartCreditNoteTableMap::AMOUNT_PRICE, $amountPrice['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($amountPrice['max'])) {
$this->addUsingAlias(CartCreditNoteTableMap::AMOUNT_PRICE, $amountPrice['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CartCreditNoteTableMap::AMOUNT_PRICE, $amountPrice, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(CartCreditNoteTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(CartCreditNoteTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CartCreditNoteTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(CartCreditNoteTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(CartCreditNoteTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CartCreditNoteTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\Cart object
*
* @param \Thelia\Model\Cart|ObjectCollection $cart The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function filterByCart($cart, $comparison = null)
{
if ($cart instanceof \Thelia\Model\Cart) {
return $this
->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cart->getId(), $comparison);
} elseif ($cart instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CartCreditNoteTableMap::CART_ID, $cart->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCart() only accepts arguments of type \Thelia\Model\Cart or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Cart relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function joinCart($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Cart');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Cart');
}
return $this;
}
/**
* Use the Cart relation Cart object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\CartQuery A secondary query class using the current class as primary query
*/
public function useCartQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCart($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Cart', '\Thelia\Model\CartQuery');
}
/**
* Filter the query by a related \CreditNote\Model\CreditNote object
*
* @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function filterByCreditNote($creditNote, $comparison = null)
{
if ($creditNote instanceof \CreditNote\Model\CreditNote) {
return $this
->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNote->getId(), $comparison);
} elseif ($creditNote instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CartCreditNoteTableMap::CREDIT_NOTE_ID, $creditNote->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
}
}
/**
* Adds a JOIN clause to the query using the CreditNote relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CreditNote');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CreditNote');
}
return $this;
}
/**
* Use the CreditNote relation CreditNote object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
*/
public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCreditNote($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
}
/**
* Exclude object from result
*
* @param ChildCartCreditNote $cartCreditNote Object to remove from the list of results
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function prune($cartCreditNote = null)
{
if ($cartCreditNote) {
$this->addCond('pruneCond0', $this->getAliasedColName(CartCreditNoteTableMap::CART_ID), $cartCreditNote->getCartId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(CartCreditNoteTableMap::CREDIT_NOTE_ID), $cartCreditNote->getCreditNoteId(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
}
/**
* Deletes all rows from the cart_credit_note table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CartCreditNoteTableMap::clearInstancePool();
CartCreditNoteTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildCartCreditNote or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildCartCreditNote object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(CartCreditNoteTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
CartCreditNoteTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
CartCreditNoteTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(CartCreditNoteTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(CartCreditNoteTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(CartCreditNoteTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(CartCreditNoteTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(CartCreditNoteTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildCartCreditNoteQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(CartCreditNoteTableMap::CREATED_AT);
}
} // CartCreditNoteQuery

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,793 @@
<?php
namespace CreditNote\Model\Base;
use \Exception;
use \PDO;
use CreditNote\Model\CreditNoteComment as ChildCreditNoteComment;
use CreditNote\Model\CreditNoteCommentQuery as ChildCreditNoteCommentQuery;
use CreditNote\Model\Map\CreditNoteCommentTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\Admin;
/**
* Base class that represents a query for the 'credit_note_comment' table.
*
*
*
* @method ChildCreditNoteCommentQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildCreditNoteCommentQuery orderByCreditNoteId($order = Criteria::ASC) Order by the credit_note_id column
* @method ChildCreditNoteCommentQuery orderByAdminId($order = Criteria::ASC) Order by the admin_id column
* @method ChildCreditNoteCommentQuery orderByComment($order = Criteria::ASC) Order by the comment column
* @method ChildCreditNoteCommentQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCreditNoteCommentQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildCreditNoteCommentQuery groupById() Group by the id column
* @method ChildCreditNoteCommentQuery groupByCreditNoteId() Group by the credit_note_id column
* @method ChildCreditNoteCommentQuery groupByAdminId() Group by the admin_id column
* @method ChildCreditNoteCommentQuery groupByComment() Group by the comment column
* @method ChildCreditNoteCommentQuery groupByCreatedAt() Group by the created_at column
* @method ChildCreditNoteCommentQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildCreditNoteCommentQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildCreditNoteCommentQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildCreditNoteCommentQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildCreditNoteCommentQuery leftJoinCreditNote($relationAlias = null) Adds a LEFT JOIN clause to the query using the CreditNote relation
* @method ChildCreditNoteCommentQuery rightJoinCreditNote($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CreditNote relation
* @method ChildCreditNoteCommentQuery innerJoinCreditNote($relationAlias = null) Adds a INNER JOIN clause to the query using the CreditNote relation
*
* @method ChildCreditNoteCommentQuery leftJoinAdmin($relationAlias = null) Adds a LEFT JOIN clause to the query using the Admin relation
* @method ChildCreditNoteCommentQuery rightJoinAdmin($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Admin relation
* @method ChildCreditNoteCommentQuery innerJoinAdmin($relationAlias = null) Adds a INNER JOIN clause to the query using the Admin relation
*
* @method ChildCreditNoteComment findOne(ConnectionInterface $con = null) Return the first ChildCreditNoteComment matching the query
* @method ChildCreditNoteComment findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCreditNoteComment matching the query, or a new ChildCreditNoteComment object populated from the query conditions when no match is found
*
* @method ChildCreditNoteComment findOneById(int $id) Return the first ChildCreditNoteComment filtered by the id column
* @method ChildCreditNoteComment findOneByCreditNoteId(int $credit_note_id) Return the first ChildCreditNoteComment filtered by the credit_note_id column
* @method ChildCreditNoteComment findOneByAdminId(int $admin_id) Return the first ChildCreditNoteComment filtered by the admin_id column
* @method ChildCreditNoteComment findOneByComment(string $comment) Return the first ChildCreditNoteComment filtered by the comment column
* @method ChildCreditNoteComment findOneByCreatedAt(string $created_at) Return the first ChildCreditNoteComment filtered by the created_at column
* @method ChildCreditNoteComment findOneByUpdatedAt(string $updated_at) Return the first ChildCreditNoteComment filtered by the updated_at column
*
* @method array findById(int $id) Return ChildCreditNoteComment objects filtered by the id column
* @method array findByCreditNoteId(int $credit_note_id) Return ChildCreditNoteComment objects filtered by the credit_note_id column
* @method array findByAdminId(int $admin_id) Return ChildCreditNoteComment objects filtered by the admin_id column
* @method array findByComment(string $comment) Return ChildCreditNoteComment objects filtered by the comment column
* @method array findByCreatedAt(string $created_at) Return ChildCreditNoteComment objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCreditNoteComment objects filtered by the updated_at column
*
*/
abstract class CreditNoteCommentQuery extends ModelCriteria
{
/**
* Initializes internal state of \CreditNote\Model\Base\CreditNoteCommentQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\CreditNote\\Model\\CreditNoteComment', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildCreditNoteCommentQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildCreditNoteCommentQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \CreditNote\Model\CreditNoteCommentQuery) {
return $criteria;
}
$query = new \CreditNote\Model\CreditNoteCommentQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildCreditNoteComment|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = CreditNoteCommentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(CreditNoteCommentTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteComment A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, CREDIT_NOTE_ID, ADMIN_ID, COMMENT, CREATED_AT, UPDATED_AT FROM credit_note_comment WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildCreditNoteComment();
$obj->hydrate($row);
CreditNoteCommentTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteComment|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(CreditNoteCommentTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(CreditNoteCommentTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteCommentTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the credit_note_id column
*
* Example usage:
* <code>
* $query->filterByCreditNoteId(1234); // WHERE credit_note_id = 1234
* $query->filterByCreditNoteId(array(12, 34)); // WHERE credit_note_id IN (12, 34)
* $query->filterByCreditNoteId(array('min' => 12)); // WHERE credit_note_id > 12
* </code>
*
* @see filterByCreditNote()
*
* @param mixed $creditNoteId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterByCreditNoteId($creditNoteId = null, $comparison = null)
{
if (is_array($creditNoteId)) {
$useMinMax = false;
if (isset($creditNoteId['min'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNoteId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($creditNoteId['max'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNoteId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNoteId, $comparison);
}
/**
* Filter the query on the admin_id column
*
* Example usage:
* <code>
* $query->filterByAdminId(1234); // WHERE admin_id = 1234
* $query->filterByAdminId(array(12, 34)); // WHERE admin_id IN (12, 34)
* $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12
* </code>
*
* @see filterByAdmin()
*
* @param mixed $adminId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterByAdminId($adminId = null, $comparison = null)
{
if (is_array($adminId)) {
$useMinMax = false;
if (isset($adminId['min'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $adminId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($adminId['max'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $adminId, $comparison);
}
/**
* Filter the query on the comment column
*
* Example usage:
* <code>
* $query->filterByComment('fooValue'); // WHERE comment = 'fooValue'
* $query->filterByComment('%fooValue%'); // WHERE comment LIKE '%fooValue%'
* </code>
*
* @param string $comment The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterByComment($comment = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($comment)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $comment)) {
$comment = str_replace('*', '%', $comment);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteCommentTableMap::COMMENT, $comment, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteCommentTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(CreditNoteCommentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteCommentTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query by a related \CreditNote\Model\CreditNote object
*
* @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterByCreditNote($creditNote, $comparison = null)
{
if ($creditNote instanceof \CreditNote\Model\CreditNote) {
return $this
->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNote->getId(), $comparison);
} elseif ($creditNote instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CreditNoteCommentTableMap::CREDIT_NOTE_ID, $creditNote->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
}
}
/**
* Adds a JOIN clause to the query using the CreditNote relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CreditNote');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CreditNote');
}
return $this;
}
/**
* Use the CreditNote relation CreditNote object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
*/
public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCreditNote($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
}
/**
* Filter the query by a related \Thelia\Model\Admin object
*
* @param \Thelia\Model\Admin|ObjectCollection $admin The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function filterByAdmin($admin, $comparison = null)
{
if ($admin instanceof \Thelia\Model\Admin) {
return $this
->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $admin->getId(), $comparison);
} elseif ($admin instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CreditNoteCommentTableMap::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByAdmin() only accepts arguments of type \Thelia\Model\Admin or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Admin relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function joinAdmin($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Admin');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Admin');
}
return $this;
}
/**
* Use the Admin relation Admin object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\AdminQuery A secondary query class using the current class as primary query
*/
public function useAdminQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinAdmin($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Admin', '\Thelia\Model\AdminQuery');
}
/**
* Exclude object from result
*
* @param ChildCreditNoteComment $creditNoteComment Object to remove from the list of results
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function prune($creditNoteComment = null)
{
if ($creditNoteComment) {
$this->addUsingAlias(CreditNoteCommentTableMap::ID, $creditNoteComment->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the credit_note_comment table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CreditNoteCommentTableMap::clearInstancePool();
CreditNoteCommentTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildCreditNoteComment or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildCreditNoteComment object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(CreditNoteCommentTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
CreditNoteCommentTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
CreditNoteCommentTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(CreditNoteCommentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(CreditNoteCommentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(CreditNoteCommentTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(CreditNoteCommentTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(CreditNoteCommentTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildCreditNoteCommentQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(CreditNoteCommentTableMap::CREATED_AT);
}
} // CreditNoteCommentQuery

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,835 @@
<?php
namespace CreditNote\Model\Base;
use \Exception;
use \PDO;
use CreditNote\Model\CreditNoteStatusFlow as ChildCreditNoteStatusFlow;
use CreditNote\Model\CreditNoteStatusFlowQuery as ChildCreditNoteStatusFlowQuery;
use CreditNote\Model\Map\CreditNoteStatusFlowTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
/**
* Base class that represents a query for the 'credit_note_status_flow' table.
*
*
*
* @method ChildCreditNoteStatusFlowQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildCreditNoteStatusFlowQuery orderByFromStatusId($order = Criteria::ASC) Order by the from_status_id column
* @method ChildCreditNoteStatusFlowQuery orderByToStatusId($order = Criteria::ASC) Order by the to_status_id column
* @method ChildCreditNoteStatusFlowQuery orderByPriority($order = Criteria::ASC) Order by the priority column
* @method ChildCreditNoteStatusFlowQuery orderByRoot($order = Criteria::ASC) Order by the root column
* @method ChildCreditNoteStatusFlowQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCreditNoteStatusFlowQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildCreditNoteStatusFlowQuery groupById() Group by the id column
* @method ChildCreditNoteStatusFlowQuery groupByFromStatusId() Group by the from_status_id column
* @method ChildCreditNoteStatusFlowQuery groupByToStatusId() Group by the to_status_id column
* @method ChildCreditNoteStatusFlowQuery groupByPriority() Group by the priority column
* @method ChildCreditNoteStatusFlowQuery groupByRoot() Group by the root column
* @method ChildCreditNoteStatusFlowQuery groupByCreatedAt() Group by the created_at column
* @method ChildCreditNoteStatusFlowQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildCreditNoteStatusFlowQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildCreditNoteStatusFlowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildCreditNoteStatusFlowQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildCreditNoteStatusFlowQuery leftJoinCreditNoteStatusRelatedByFromStatusId($relationAlias = null) Adds a LEFT JOIN clause to the query using the CreditNoteStatusRelatedByFromStatusId relation
* @method ChildCreditNoteStatusFlowQuery rightJoinCreditNoteStatusRelatedByFromStatusId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CreditNoteStatusRelatedByFromStatusId relation
* @method ChildCreditNoteStatusFlowQuery innerJoinCreditNoteStatusRelatedByFromStatusId($relationAlias = null) Adds a INNER JOIN clause to the query using the CreditNoteStatusRelatedByFromStatusId relation
*
* @method ChildCreditNoteStatusFlowQuery leftJoinCreditNoteStatusRelatedByToStatusId($relationAlias = null) Adds a LEFT JOIN clause to the query using the CreditNoteStatusRelatedByToStatusId relation
* @method ChildCreditNoteStatusFlowQuery rightJoinCreditNoteStatusRelatedByToStatusId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CreditNoteStatusRelatedByToStatusId relation
* @method ChildCreditNoteStatusFlowQuery innerJoinCreditNoteStatusRelatedByToStatusId($relationAlias = null) Adds a INNER JOIN clause to the query using the CreditNoteStatusRelatedByToStatusId relation
*
* @method ChildCreditNoteStatusFlow findOne(ConnectionInterface $con = null) Return the first ChildCreditNoteStatusFlow matching the query
* @method ChildCreditNoteStatusFlow findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCreditNoteStatusFlow matching the query, or a new ChildCreditNoteStatusFlow object populated from the query conditions when no match is found
*
* @method ChildCreditNoteStatusFlow findOneById(int $id) Return the first ChildCreditNoteStatusFlow filtered by the id column
* @method ChildCreditNoteStatusFlow findOneByFromStatusId(int $from_status_id) Return the first ChildCreditNoteStatusFlow filtered by the from_status_id column
* @method ChildCreditNoteStatusFlow findOneByToStatusId(int $to_status_id) Return the first ChildCreditNoteStatusFlow filtered by the to_status_id column
* @method ChildCreditNoteStatusFlow findOneByPriority(int $priority) Return the first ChildCreditNoteStatusFlow filtered by the priority column
* @method ChildCreditNoteStatusFlow findOneByRoot(boolean $root) Return the first ChildCreditNoteStatusFlow filtered by the root column
* @method ChildCreditNoteStatusFlow findOneByCreatedAt(string $created_at) Return the first ChildCreditNoteStatusFlow filtered by the created_at column
* @method ChildCreditNoteStatusFlow findOneByUpdatedAt(string $updated_at) Return the first ChildCreditNoteStatusFlow filtered by the updated_at column
*
* @method array findById(int $id) Return ChildCreditNoteStatusFlow objects filtered by the id column
* @method array findByFromStatusId(int $from_status_id) Return ChildCreditNoteStatusFlow objects filtered by the from_status_id column
* @method array findByToStatusId(int $to_status_id) Return ChildCreditNoteStatusFlow objects filtered by the to_status_id column
* @method array findByPriority(int $priority) Return ChildCreditNoteStatusFlow objects filtered by the priority column
* @method array findByRoot(boolean $root) Return ChildCreditNoteStatusFlow objects filtered by the root column
* @method array findByCreatedAt(string $created_at) Return ChildCreditNoteStatusFlow objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCreditNoteStatusFlow objects filtered by the updated_at column
*
*/
abstract class CreditNoteStatusFlowQuery extends ModelCriteria
{
/**
* Initializes internal state of \CreditNote\Model\Base\CreditNoteStatusFlowQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\CreditNote\\Model\\CreditNoteStatusFlow', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildCreditNoteStatusFlowQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildCreditNoteStatusFlowQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \CreditNote\Model\CreditNoteStatusFlowQuery) {
return $criteria;
}
$query = new \CreditNote\Model\CreditNoteStatusFlowQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildCreditNoteStatusFlow|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = CreditNoteStatusFlowTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteStatusFlow A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, FROM_STATUS_ID, TO_STATUS_ID, PRIORITY, ROOT, CREATED_AT, UPDATED_AT FROM credit_note_status_flow WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildCreditNoteStatusFlow();
$obj->hydrate($row);
CreditNoteStatusFlowTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteStatusFlow|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the from_status_id column
*
* Example usage:
* <code>
* $query->filterByFromStatusId(1234); // WHERE from_status_id = 1234
* $query->filterByFromStatusId(array(12, 34)); // WHERE from_status_id IN (12, 34)
* $query->filterByFromStatusId(array('min' => 12)); // WHERE from_status_id > 12
* </code>
*
* @see filterByCreditNoteStatusRelatedByFromStatusId()
*
* @param mixed $fromStatusId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByFromStatusId($fromStatusId = null, $comparison = null)
{
if (is_array($fromStatusId)) {
$useMinMax = false;
if (isset($fromStatusId['min'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $fromStatusId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($fromStatusId['max'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $fromStatusId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $fromStatusId, $comparison);
}
/**
* Filter the query on the to_status_id column
*
* Example usage:
* <code>
* $query->filterByToStatusId(1234); // WHERE to_status_id = 1234
* $query->filterByToStatusId(array(12, 34)); // WHERE to_status_id IN (12, 34)
* $query->filterByToStatusId(array('min' => 12)); // WHERE to_status_id > 12
* </code>
*
* @see filterByCreditNoteStatusRelatedByToStatusId()
*
* @param mixed $toStatusId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByToStatusId($toStatusId = null, $comparison = null)
{
if (is_array($toStatusId)) {
$useMinMax = false;
if (isset($toStatusId['min'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $toStatusId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($toStatusId['max'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $toStatusId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $toStatusId, $comparison);
}
/**
* Filter the query on the priority column
*
* Example usage:
* <code>
* $query->filterByPriority(1234); // WHERE priority = 1234
* $query->filterByPriority(array(12, 34)); // WHERE priority IN (12, 34)
* $query->filterByPriority(array('min' => 12)); // WHERE priority > 12
* </code>
*
* @param mixed $priority The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByPriority($priority = null, $comparison = null)
{
if (is_array($priority)) {
$useMinMax = false;
if (isset($priority['min'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::PRIORITY, $priority['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($priority['max'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::PRIORITY, $priority['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::PRIORITY, $priority, $comparison);
}
/**
* Filter the query on the root column
*
* Example usage:
* <code>
* $query->filterByRoot(true); // WHERE root = true
* $query->filterByRoot('yes'); // WHERE root = true
* </code>
*
* @param boolean|string $root The value to use as filter.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByRoot($root = null, $comparison = null)
{
if (is_string($root)) {
$root = in_array(strtolower($root), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::ROOT, $root, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query by a related \CreditNote\Model\CreditNoteStatus object
*
* @param \CreditNote\Model\CreditNoteStatus|ObjectCollection $creditNoteStatus The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByCreditNoteStatusRelatedByFromStatusId($creditNoteStatus, $comparison = null)
{
if ($creditNoteStatus instanceof \CreditNote\Model\CreditNoteStatus) {
return $this
->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $creditNoteStatus->getId(), $comparison);
} elseif ($creditNoteStatus instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CreditNoteStatusFlowTableMap::FROM_STATUS_ID, $creditNoteStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCreditNoteStatusRelatedByFromStatusId() only accepts arguments of type \CreditNote\Model\CreditNoteStatus or Collection');
}
}
/**
* Adds a JOIN clause to the query using the CreditNoteStatusRelatedByFromStatusId relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function joinCreditNoteStatusRelatedByFromStatusId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CreditNoteStatusRelatedByFromStatusId');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CreditNoteStatusRelatedByFromStatusId');
}
return $this;
}
/**
* Use the CreditNoteStatusRelatedByFromStatusId relation CreditNoteStatus object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \CreditNote\Model\CreditNoteStatusQuery A secondary query class using the current class as primary query
*/
public function useCreditNoteStatusRelatedByFromStatusIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCreditNoteStatusRelatedByFromStatusId($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatusRelatedByFromStatusId', '\CreditNote\Model\CreditNoteStatusQuery');
}
/**
* Filter the query by a related \CreditNote\Model\CreditNoteStatus object
*
* @param \CreditNote\Model\CreditNoteStatus|ObjectCollection $creditNoteStatus The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function filterByCreditNoteStatusRelatedByToStatusId($creditNoteStatus, $comparison = null)
{
if ($creditNoteStatus instanceof \CreditNote\Model\CreditNoteStatus) {
return $this
->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $creditNoteStatus->getId(), $comparison);
} elseif ($creditNoteStatus instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CreditNoteStatusFlowTableMap::TO_STATUS_ID, $creditNoteStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCreditNoteStatusRelatedByToStatusId() only accepts arguments of type \CreditNote\Model\CreditNoteStatus or Collection');
}
}
/**
* Adds a JOIN clause to the query using the CreditNoteStatusRelatedByToStatusId relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function joinCreditNoteStatusRelatedByToStatusId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CreditNoteStatusRelatedByToStatusId');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CreditNoteStatusRelatedByToStatusId');
}
return $this;
}
/**
* Use the CreditNoteStatusRelatedByToStatusId relation CreditNoteStatus object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \CreditNote\Model\CreditNoteStatusQuery A secondary query class using the current class as primary query
*/
public function useCreditNoteStatusRelatedByToStatusIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCreditNoteStatusRelatedByToStatusId($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatusRelatedByToStatusId', '\CreditNote\Model\CreditNoteStatusQuery');
}
/**
* Exclude object from result
*
* @param ChildCreditNoteStatusFlow $creditNoteStatusFlow Object to remove from the list of results
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function prune($creditNoteStatusFlow = null)
{
if ($creditNoteStatusFlow) {
$this->addUsingAlias(CreditNoteStatusFlowTableMap::ID, $creditNoteStatusFlow->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the credit_note_status_flow table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CreditNoteStatusFlowTableMap::clearInstancePool();
CreditNoteStatusFlowTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildCreditNoteStatusFlow or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildCreditNoteStatusFlow object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(CreditNoteStatusFlowTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
CreditNoteStatusFlowTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
CreditNoteStatusFlowTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(CreditNoteStatusFlowTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(CreditNoteStatusFlowTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(CreditNoteStatusFlowTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(CreditNoteStatusFlowTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildCreditNoteStatusFlowQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(CreditNoteStatusFlowTableMap::CREATED_AT);
}
} // CreditNoteStatusFlowQuery

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,607 @@
<?php
namespace CreditNote\Model\Base;
use \Exception;
use \PDO;
use CreditNote\Model\CreditNoteStatusI18n as ChildCreditNoteStatusI18n;
use CreditNote\Model\CreditNoteStatusI18nQuery as ChildCreditNoteStatusI18nQuery;
use CreditNote\Model\Map\CreditNoteStatusI18nTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
/**
* Base class that represents a query for the 'credit_note_status_i18n' table.
*
*
*
* @method ChildCreditNoteStatusI18nQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildCreditNoteStatusI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
* @method ChildCreditNoteStatusI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
* @method ChildCreditNoteStatusI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
* @method ChildCreditNoteStatusI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column
* @method ChildCreditNoteStatusI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column
*
* @method ChildCreditNoteStatusI18nQuery groupById() Group by the id column
* @method ChildCreditNoteStatusI18nQuery groupByLocale() Group by the locale column
* @method ChildCreditNoteStatusI18nQuery groupByTitle() Group by the title column
* @method ChildCreditNoteStatusI18nQuery groupByDescription() Group by the description column
* @method ChildCreditNoteStatusI18nQuery groupByChapo() Group by the chapo column
* @method ChildCreditNoteStatusI18nQuery groupByPostscriptum() Group by the postscriptum column
*
* @method ChildCreditNoteStatusI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildCreditNoteStatusI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildCreditNoteStatusI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildCreditNoteStatusI18nQuery leftJoinCreditNoteStatus($relationAlias = null) Adds a LEFT JOIN clause to the query using the CreditNoteStatus relation
* @method ChildCreditNoteStatusI18nQuery rightJoinCreditNoteStatus($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CreditNoteStatus relation
* @method ChildCreditNoteStatusI18nQuery innerJoinCreditNoteStatus($relationAlias = null) Adds a INNER JOIN clause to the query using the CreditNoteStatus relation
*
* @method ChildCreditNoteStatusI18n findOne(ConnectionInterface $con = null) Return the first ChildCreditNoteStatusI18n matching the query
* @method ChildCreditNoteStatusI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCreditNoteStatusI18n matching the query, or a new ChildCreditNoteStatusI18n object populated from the query conditions when no match is found
*
* @method ChildCreditNoteStatusI18n findOneById(int $id) Return the first ChildCreditNoteStatusI18n filtered by the id column
* @method ChildCreditNoteStatusI18n findOneByLocale(string $locale) Return the first ChildCreditNoteStatusI18n filtered by the locale column
* @method ChildCreditNoteStatusI18n findOneByTitle(string $title) Return the first ChildCreditNoteStatusI18n filtered by the title column
* @method ChildCreditNoteStatusI18n findOneByDescription(string $description) Return the first ChildCreditNoteStatusI18n filtered by the description column
* @method ChildCreditNoteStatusI18n findOneByChapo(string $chapo) Return the first ChildCreditNoteStatusI18n filtered by the chapo column
* @method ChildCreditNoteStatusI18n findOneByPostscriptum(string $postscriptum) Return the first ChildCreditNoteStatusI18n filtered by the postscriptum column
*
* @method array findById(int $id) Return ChildCreditNoteStatusI18n objects filtered by the id column
* @method array findByLocale(string $locale) Return ChildCreditNoteStatusI18n objects filtered by the locale column
* @method array findByTitle(string $title) Return ChildCreditNoteStatusI18n objects filtered by the title column
* @method array findByDescription(string $description) Return ChildCreditNoteStatusI18n objects filtered by the description column
* @method array findByChapo(string $chapo) Return ChildCreditNoteStatusI18n objects filtered by the chapo column
* @method array findByPostscriptum(string $postscriptum) Return ChildCreditNoteStatusI18n objects filtered by the postscriptum column
*
*/
abstract class CreditNoteStatusI18nQuery extends ModelCriteria
{
/**
* Initializes internal state of \CreditNote\Model\Base\CreditNoteStatusI18nQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\CreditNote\\Model\\CreditNoteStatusI18n', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildCreditNoteStatusI18nQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildCreditNoteStatusI18nQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \CreditNote\Model\CreditNoteStatusI18nQuery) {
return $criteria;
}
$query = new \CreditNote\Model\CreditNoteStatusI18nQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array[$id, $locale] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildCreditNoteStatusI18n|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = CreditNoteStatusI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteStatusI18n A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM credit_note_status_i18n WHERE ID = :p0 AND LOCALE = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
$stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildCreditNoteStatusI18n();
$obj->hydrate($row);
CreditNoteStatusI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteStatusI18n|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
$this->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(CreditNoteStatusI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
return $this;
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(CreditNoteStatusI18nTableMap::ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(CreditNoteStatusI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @see filterByCreditNoteStatus()
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the locale column
*
* Example usage:
* <code>
* $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
* $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
* </code>
*
* @param string $locale The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function filterByLocale($locale = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($locale)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $locale)) {
$locale = str_replace('*', '%', $locale);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteStatusI18nTableMap::LOCALE, $locale, $comparison);
}
/**
* Filter the query on the title column
*
* Example usage:
* <code>
* $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
* $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
* </code>
*
* @param string $title The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function filterByTitle($title = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($title)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $title)) {
$title = str_replace('*', '%', $title);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteStatusI18nTableMap::TITLE, $title, $comparison);
}
/**
* Filter the query on the description column
*
* Example usage:
* <code>
* $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
* $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
* </code>
*
* @param string $description The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function filterByDescription($description = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($description)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $description)) {
$description = str_replace('*', '%', $description);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteStatusI18nTableMap::DESCRIPTION, $description, $comparison);
}
/**
* Filter the query on the chapo column
*
* Example usage:
* <code>
* $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
* $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
* </code>
*
* @param string $chapo The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function filterByChapo($chapo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($chapo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $chapo)) {
$chapo = str_replace('*', '%', $chapo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteStatusI18nTableMap::CHAPO, $chapo, $comparison);
}
/**
* Filter the query on the postscriptum column
*
* Example usage:
* <code>
* $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
* $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
* </code>
*
* @param string $postscriptum The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function filterByPostscriptum($postscriptum = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($postscriptum)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $postscriptum)) {
$postscriptum = str_replace('*', '%', $postscriptum);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteStatusI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
}
/**
* Filter the query by a related \CreditNote\Model\CreditNoteStatus object
*
* @param \CreditNote\Model\CreditNoteStatus|ObjectCollection $creditNoteStatus The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function filterByCreditNoteStatus($creditNoteStatus, $comparison = null)
{
if ($creditNoteStatus instanceof \CreditNote\Model\CreditNoteStatus) {
return $this
->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $creditNoteStatus->getId(), $comparison);
} elseif ($creditNoteStatus instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CreditNoteStatusI18nTableMap::ID, $creditNoteStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCreditNoteStatus() only accepts arguments of type \CreditNote\Model\CreditNoteStatus or Collection');
}
}
/**
* Adds a JOIN clause to the query using the CreditNoteStatus relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function joinCreditNoteStatus($relationAlias = null, $joinType = 'LEFT JOIN')
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CreditNoteStatus');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CreditNoteStatus');
}
return $this;
}
/**
* Use the CreditNoteStatus relation CreditNoteStatus object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \CreditNote\Model\CreditNoteStatusQuery A secondary query class using the current class as primary query
*/
public function useCreditNoteStatusQuery($relationAlias = null, $joinType = 'LEFT JOIN')
{
return $this
->joinCreditNoteStatus($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNoteStatus', '\CreditNote\Model\CreditNoteStatusQuery');
}
/**
* Exclude object from result
*
* @param ChildCreditNoteStatusI18n $creditNoteStatusI18n Object to remove from the list of results
*
* @return ChildCreditNoteStatusI18nQuery The current query, for fluid interface
*/
public function prune($creditNoteStatusI18n = null)
{
if ($creditNoteStatusI18n) {
$this->addCond('pruneCond0', $this->getAliasedColName(CreditNoteStatusI18nTableMap::ID), $creditNoteStatusI18n->getId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(CreditNoteStatusI18nTableMap::LOCALE), $creditNoteStatusI18n->getLocale(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
}
/**
* Deletes all rows from the credit_note_status_i18n table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CreditNoteStatusI18nTableMap::clearInstancePool();
CreditNoteStatusI18nTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildCreditNoteStatusI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildCreditNoteStatusI18n object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(CreditNoteStatusI18nTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
CreditNoteStatusI18nTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
CreditNoteStatusI18nTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
} // CreditNoteStatusI18nQuery

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,607 @@
<?php
namespace CreditNote\Model\Base;
use \Exception;
use \PDO;
use CreditNote\Model\CreditNoteTypeI18n as ChildCreditNoteTypeI18n;
use CreditNote\Model\CreditNoteTypeI18nQuery as ChildCreditNoteTypeI18nQuery;
use CreditNote\Model\Map\CreditNoteTypeI18nTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
/**
* Base class that represents a query for the 'credit_note_type_i18n' table.
*
*
*
* @method ChildCreditNoteTypeI18nQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildCreditNoteTypeI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
* @method ChildCreditNoteTypeI18nQuery orderByTitle($order = Criteria::ASC) Order by the title column
* @method ChildCreditNoteTypeI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
* @method ChildCreditNoteTypeI18nQuery orderByChapo($order = Criteria::ASC) Order by the chapo column
* @method ChildCreditNoteTypeI18nQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column
*
* @method ChildCreditNoteTypeI18nQuery groupById() Group by the id column
* @method ChildCreditNoteTypeI18nQuery groupByLocale() Group by the locale column
* @method ChildCreditNoteTypeI18nQuery groupByTitle() Group by the title column
* @method ChildCreditNoteTypeI18nQuery groupByDescription() Group by the description column
* @method ChildCreditNoteTypeI18nQuery groupByChapo() Group by the chapo column
* @method ChildCreditNoteTypeI18nQuery groupByPostscriptum() Group by the postscriptum column
*
* @method ChildCreditNoteTypeI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildCreditNoteTypeI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildCreditNoteTypeI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildCreditNoteTypeI18nQuery leftJoinCreditNoteType($relationAlias = null) Adds a LEFT JOIN clause to the query using the CreditNoteType relation
* @method ChildCreditNoteTypeI18nQuery rightJoinCreditNoteType($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CreditNoteType relation
* @method ChildCreditNoteTypeI18nQuery innerJoinCreditNoteType($relationAlias = null) Adds a INNER JOIN clause to the query using the CreditNoteType relation
*
* @method ChildCreditNoteTypeI18n findOne(ConnectionInterface $con = null) Return the first ChildCreditNoteTypeI18n matching the query
* @method ChildCreditNoteTypeI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCreditNoteTypeI18n matching the query, or a new ChildCreditNoteTypeI18n object populated from the query conditions when no match is found
*
* @method ChildCreditNoteTypeI18n findOneById(int $id) Return the first ChildCreditNoteTypeI18n filtered by the id column
* @method ChildCreditNoteTypeI18n findOneByLocale(string $locale) Return the first ChildCreditNoteTypeI18n filtered by the locale column
* @method ChildCreditNoteTypeI18n findOneByTitle(string $title) Return the first ChildCreditNoteTypeI18n filtered by the title column
* @method ChildCreditNoteTypeI18n findOneByDescription(string $description) Return the first ChildCreditNoteTypeI18n filtered by the description column
* @method ChildCreditNoteTypeI18n findOneByChapo(string $chapo) Return the first ChildCreditNoteTypeI18n filtered by the chapo column
* @method ChildCreditNoteTypeI18n findOneByPostscriptum(string $postscriptum) Return the first ChildCreditNoteTypeI18n filtered by the postscriptum column
*
* @method array findById(int $id) Return ChildCreditNoteTypeI18n objects filtered by the id column
* @method array findByLocale(string $locale) Return ChildCreditNoteTypeI18n objects filtered by the locale column
* @method array findByTitle(string $title) Return ChildCreditNoteTypeI18n objects filtered by the title column
* @method array findByDescription(string $description) Return ChildCreditNoteTypeI18n objects filtered by the description column
* @method array findByChapo(string $chapo) Return ChildCreditNoteTypeI18n objects filtered by the chapo column
* @method array findByPostscriptum(string $postscriptum) Return ChildCreditNoteTypeI18n objects filtered by the postscriptum column
*
*/
abstract class CreditNoteTypeI18nQuery extends ModelCriteria
{
/**
* Initializes internal state of \CreditNote\Model\Base\CreditNoteTypeI18nQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\CreditNote\\Model\\CreditNoteTypeI18n', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildCreditNoteTypeI18nQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildCreditNoteTypeI18nQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \CreditNote\Model\CreditNoteTypeI18nQuery) {
return $criteria;
}
$query = new \CreditNote\Model\CreditNoteTypeI18nQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array[$id, $locale] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildCreditNoteTypeI18n|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = CreditNoteTypeI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteTypeI18n A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM credit_note_type_i18n WHERE ID = :p0 AND LOCALE = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
$stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildCreditNoteTypeI18n();
$obj->hydrate($row);
CreditNoteTypeI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteTypeI18n|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
$this->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(CreditNoteTypeI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
return $this;
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(CreditNoteTypeI18nTableMap::ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(CreditNoteTypeI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @see filterByCreditNoteType()
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the locale column
*
* Example usage:
* <code>
* $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
* $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
* </code>
*
* @param string $locale The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function filterByLocale($locale = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($locale)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $locale)) {
$locale = str_replace('*', '%', $locale);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteTypeI18nTableMap::LOCALE, $locale, $comparison);
}
/**
* Filter the query on the title column
*
* Example usage:
* <code>
* $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
* $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
* </code>
*
* @param string $title The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function filterByTitle($title = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($title)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $title)) {
$title = str_replace('*', '%', $title);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteTypeI18nTableMap::TITLE, $title, $comparison);
}
/**
* Filter the query on the description column
*
* Example usage:
* <code>
* $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
* $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
* </code>
*
* @param string $description The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function filterByDescription($description = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($description)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $description)) {
$description = str_replace('*', '%', $description);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteTypeI18nTableMap::DESCRIPTION, $description, $comparison);
}
/**
* Filter the query on the chapo column
*
* Example usage:
* <code>
* $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
* $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
* </code>
*
* @param string $chapo The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function filterByChapo($chapo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($chapo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $chapo)) {
$chapo = str_replace('*', '%', $chapo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteTypeI18nTableMap::CHAPO, $chapo, $comparison);
}
/**
* Filter the query on the postscriptum column
*
* Example usage:
* <code>
* $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
* $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
* </code>
*
* @param string $postscriptum The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function filterByPostscriptum($postscriptum = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($postscriptum)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $postscriptum)) {
$postscriptum = str_replace('*', '%', $postscriptum);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteTypeI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
}
/**
* Filter the query by a related \CreditNote\Model\CreditNoteType object
*
* @param \CreditNote\Model\CreditNoteType|ObjectCollection $creditNoteType The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function filterByCreditNoteType($creditNoteType, $comparison = null)
{
if ($creditNoteType instanceof \CreditNote\Model\CreditNoteType) {
return $this
->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $creditNoteType->getId(), $comparison);
} elseif ($creditNoteType instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CreditNoteTypeI18nTableMap::ID, $creditNoteType->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCreditNoteType() only accepts arguments of type \CreditNote\Model\CreditNoteType or Collection');
}
}
/**
* Adds a JOIN clause to the query using the CreditNoteType relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function joinCreditNoteType($relationAlias = null, $joinType = 'LEFT JOIN')
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CreditNoteType');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CreditNoteType');
}
return $this;
}
/**
* Use the CreditNoteType relation CreditNoteType object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \CreditNote\Model\CreditNoteTypeQuery A secondary query class using the current class as primary query
*/
public function useCreditNoteTypeQuery($relationAlias = null, $joinType = 'LEFT JOIN')
{
return $this
->joinCreditNoteType($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNoteType', '\CreditNote\Model\CreditNoteTypeQuery');
}
/**
* Exclude object from result
*
* @param ChildCreditNoteTypeI18n $creditNoteTypeI18n Object to remove from the list of results
*
* @return ChildCreditNoteTypeI18nQuery The current query, for fluid interface
*/
public function prune($creditNoteTypeI18n = null)
{
if ($creditNoteTypeI18n) {
$this->addCond('pruneCond0', $this->getAliasedColName(CreditNoteTypeI18nTableMap::ID), $creditNoteTypeI18n->getId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(CreditNoteTypeI18nTableMap::LOCALE), $creditNoteTypeI18n->getLocale(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
}
/**
* Deletes all rows from the credit_note_type_i18n table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CreditNoteTypeI18nTableMap::clearInstancePool();
CreditNoteTypeI18nTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildCreditNoteTypeI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildCreditNoteTypeI18n object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(CreditNoteTypeI18nTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
CreditNoteTypeI18nTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
CreditNoteTypeI18nTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
} // CreditNoteTypeI18nQuery

View File

@@ -0,0 +1,861 @@
<?php
namespace CreditNote\Model\Base;
use \Exception;
use \PDO;
use CreditNote\Model\CreditNoteType as ChildCreditNoteType;
use CreditNote\Model\CreditNoteTypeI18nQuery as ChildCreditNoteTypeI18nQuery;
use CreditNote\Model\CreditNoteTypeQuery as ChildCreditNoteTypeQuery;
use CreditNote\Model\Map\CreditNoteTypeTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
/**
* Base class that represents a query for the 'credit_note_type' table.
*
*
*
* @method ChildCreditNoteTypeQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildCreditNoteTypeQuery orderByCode($order = Criteria::ASC) Order by the code column
* @method ChildCreditNoteTypeQuery orderByColor($order = Criteria::ASC) Order by the color column
* @method ChildCreditNoteTypeQuery orderByPosition($order = Criteria::ASC) Order by the position column
* @method ChildCreditNoteTypeQuery orderByRequiredOrder($order = Criteria::ASC) Order by the required_order column
* @method ChildCreditNoteTypeQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCreditNoteTypeQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildCreditNoteTypeQuery groupById() Group by the id column
* @method ChildCreditNoteTypeQuery groupByCode() Group by the code column
* @method ChildCreditNoteTypeQuery groupByColor() Group by the color column
* @method ChildCreditNoteTypeQuery groupByPosition() Group by the position column
* @method ChildCreditNoteTypeQuery groupByRequiredOrder() Group by the required_order column
* @method ChildCreditNoteTypeQuery groupByCreatedAt() Group by the created_at column
* @method ChildCreditNoteTypeQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildCreditNoteTypeQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildCreditNoteTypeQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildCreditNoteTypeQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildCreditNoteTypeQuery leftJoinCreditNote($relationAlias = null) Adds a LEFT JOIN clause to the query using the CreditNote relation
* @method ChildCreditNoteTypeQuery rightJoinCreditNote($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CreditNote relation
* @method ChildCreditNoteTypeQuery innerJoinCreditNote($relationAlias = null) Adds a INNER JOIN clause to the query using the CreditNote relation
*
* @method ChildCreditNoteTypeQuery leftJoinCreditNoteTypeI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CreditNoteTypeI18n relation
* @method ChildCreditNoteTypeQuery rightJoinCreditNoteTypeI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CreditNoteTypeI18n relation
* @method ChildCreditNoteTypeQuery innerJoinCreditNoteTypeI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CreditNoteTypeI18n relation
*
* @method ChildCreditNoteType findOne(ConnectionInterface $con = null) Return the first ChildCreditNoteType matching the query
* @method ChildCreditNoteType findOneOrCreate(ConnectionInterface $con = null) Return the first ChildCreditNoteType matching the query, or a new ChildCreditNoteType object populated from the query conditions when no match is found
*
* @method ChildCreditNoteType findOneById(int $id) Return the first ChildCreditNoteType filtered by the id column
* @method ChildCreditNoteType findOneByCode(string $code) Return the first ChildCreditNoteType filtered by the code column
* @method ChildCreditNoteType findOneByColor(string $color) Return the first ChildCreditNoteType filtered by the color column
* @method ChildCreditNoteType findOneByPosition(int $position) Return the first ChildCreditNoteType filtered by the position column
* @method ChildCreditNoteType findOneByRequiredOrder(boolean $required_order) Return the first ChildCreditNoteType filtered by the required_order column
* @method ChildCreditNoteType findOneByCreatedAt(string $created_at) Return the first ChildCreditNoteType filtered by the created_at column
* @method ChildCreditNoteType findOneByUpdatedAt(string $updated_at) Return the first ChildCreditNoteType filtered by the updated_at column
*
* @method array findById(int $id) Return ChildCreditNoteType objects filtered by the id column
* @method array findByCode(string $code) Return ChildCreditNoteType objects filtered by the code column
* @method array findByColor(string $color) Return ChildCreditNoteType objects filtered by the color column
* @method array findByPosition(int $position) Return ChildCreditNoteType objects filtered by the position column
* @method array findByRequiredOrder(boolean $required_order) Return ChildCreditNoteType objects filtered by the required_order column
* @method array findByCreatedAt(string $created_at) Return ChildCreditNoteType objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCreditNoteType objects filtered by the updated_at column
*
*/
abstract class CreditNoteTypeQuery extends ModelCriteria
{
/**
* Initializes internal state of \CreditNote\Model\Base\CreditNoteTypeQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\CreditNote\\Model\\CreditNoteType', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildCreditNoteTypeQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildCreditNoteTypeQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \CreditNote\Model\CreditNoteTypeQuery) {
return $criteria;
}
$query = new \CreditNote\Model\CreditNoteTypeQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(12, $con);
* </code>
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildCreditNoteType|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = CreditNoteTypeTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(CreditNoteTypeTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteType A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, CODE, COLOR, POSITION, REQUIRED_ORDER, CREATED_AT, UPDATED_AT FROM credit_note_type WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildCreditNoteType();
$obj->hydrate($row);
CreditNoteTypeTableMap::addInstanceToPool($obj, (string) $key);
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildCreditNoteType|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(12, 56, 832), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
return $this->addUsingAlias(CreditNoteTypeTableMap::ID, $key, Criteria::EQUAL);
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
return $this->addUsingAlias(CreditNoteTypeTableMap::ID, $keys, Criteria::IN);
}
/**
* Filter the query on the id column
*
* Example usage:
* <code>
* $query->filterById(1234); // WHERE id = 1234
* $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
* $query->filterById(array('min' => 12)); // WHERE id > 12
* </code>
*
* @param mixed $id The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterById($id = null, $comparison = null)
{
if (is_array($id)) {
$useMinMax = false;
if (isset($id['min'])) {
$this->addUsingAlias(CreditNoteTypeTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($id['max'])) {
$this->addUsingAlias(CreditNoteTypeTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteTypeTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the code column
*
* Example usage:
* <code>
* $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
* $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
* </code>
*
* @param string $code The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByCode($code = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($code)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $code)) {
$code = str_replace('*', '%', $code);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteTypeTableMap::CODE, $code, $comparison);
}
/**
* Filter the query on the color column
*
* Example usage:
* <code>
* $query->filterByColor('fooValue'); // WHERE color = 'fooValue'
* $query->filterByColor('%fooValue%'); // WHERE color LIKE '%fooValue%'
* </code>
*
* @param string $color The value to use as filter.
* Accepts wildcards (* and % trigger a LIKE)
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByColor($color = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($color)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $color)) {
$color = str_replace('*', '%', $color);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CreditNoteTypeTableMap::COLOR, $color, $comparison);
}
/**
* Filter the query on the position column
*
* Example usage:
* <code>
* $query->filterByPosition(1234); // WHERE position = 1234
* $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
* $query->filterByPosition(array('min' => 12)); // WHERE position > 12
* </code>
*
* @param mixed $position The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByPosition($position = null, $comparison = null)
{
if (is_array($position)) {
$useMinMax = false;
if (isset($position['min'])) {
$this->addUsingAlias(CreditNoteTypeTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($position['max'])) {
$this->addUsingAlias(CreditNoteTypeTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteTypeTableMap::POSITION, $position, $comparison);
}
/**
* Filter the query on the required_order column
*
* Example usage:
* <code>
* $query->filterByRequiredOrder(true); // WHERE required_order = true
* $query->filterByRequiredOrder('yes'); // WHERE required_order = true
* </code>
*
* @param boolean|string $requiredOrder The value to use as filter.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByRequiredOrder($requiredOrder = null, $comparison = null)
{
if (is_string($requiredOrder)) {
$required_order = in_array(strtolower($requiredOrder), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(CreditNoteTypeTableMap::REQUIRED_ORDER, $requiredOrder, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(CreditNoteTypeTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(CreditNoteTypeTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteTypeTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(CreditNoteTypeTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(CreditNoteTypeTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CreditNoteTypeTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query by a related \CreditNote\Model\CreditNote object
*
* @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByCreditNote($creditNote, $comparison = null)
{
if ($creditNote instanceof \CreditNote\Model\CreditNote) {
return $this
->addUsingAlias(CreditNoteTypeTableMap::ID, $creditNote->getTypeId(), $comparison);
} elseif ($creditNote instanceof ObjectCollection) {
return $this
->useCreditNoteQuery()
->filterByPrimaryKeys($creditNote->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
}
}
/**
* Adds a JOIN clause to the query using the CreditNote relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CreditNote');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CreditNote');
}
return $this;
}
/**
* Use the CreditNote relation CreditNote object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
*/
public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCreditNote($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
}
/**
* Filter the query by a related \CreditNote\Model\CreditNoteTypeI18n object
*
* @param \CreditNote\Model\CreditNoteTypeI18n|ObjectCollection $creditNoteTypeI18n the related object to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function filterByCreditNoteTypeI18n($creditNoteTypeI18n, $comparison = null)
{
if ($creditNoteTypeI18n instanceof \CreditNote\Model\CreditNoteTypeI18n) {
return $this
->addUsingAlias(CreditNoteTypeTableMap::ID, $creditNoteTypeI18n->getId(), $comparison);
} elseif ($creditNoteTypeI18n instanceof ObjectCollection) {
return $this
->useCreditNoteTypeI18nQuery()
->filterByPrimaryKeys($creditNoteTypeI18n->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByCreditNoteTypeI18n() only accepts arguments of type \CreditNote\Model\CreditNoteTypeI18n or Collection');
}
}
/**
* Adds a JOIN clause to the query using the CreditNoteTypeI18n relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function joinCreditNoteTypeI18n($relationAlias = null, $joinType = 'LEFT JOIN')
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CreditNoteTypeI18n');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CreditNoteTypeI18n');
}
return $this;
}
/**
* Use the CreditNoteTypeI18n relation CreditNoteTypeI18n object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \CreditNote\Model\CreditNoteTypeI18nQuery A secondary query class using the current class as primary query
*/
public function useCreditNoteTypeI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
{
return $this
->joinCreditNoteTypeI18n($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNoteTypeI18n', '\CreditNote\Model\CreditNoteTypeI18nQuery');
}
/**
* Exclude object from result
*
* @param ChildCreditNoteType $creditNoteType Object to remove from the list of results
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function prune($creditNoteType = null)
{
if ($creditNoteType) {
$this->addUsingAlias(CreditNoteTypeTableMap::ID, $creditNoteType->getId(), Criteria::NOT_EQUAL);
}
return $this;
}
/**
* Deletes all rows from the credit_note_type table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
CreditNoteTypeTableMap::clearInstancePool();
CreditNoteTypeTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildCreditNoteType or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildCreditNoteType object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(CreditNoteTypeTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
CreditNoteTypeTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
CreditNoteTypeTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// i18n behavior
/**
* Adds a JOIN clause to the query using the i18n relation
*
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
$relationName = $relationAlias ? $relationAlias : 'CreditNoteTypeI18n';
return $this
->joinCreditNoteTypeI18n($relationAlias, $joinType)
->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
}
/**
* Adds a JOIN clause to the query and hydrates the related I18n object.
* Shortcut for $c->joinI18n($locale)->with()
*
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN)
{
$this
->joinI18n($locale, null, $joinType)
->with('CreditNoteTypeI18n');
$this->with['CreditNoteTypeI18n']->setIsWithOneToMany(false);
return $this;
}
/**
* Use the I18n relation query object
*
* @see useQuery()
*
* @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
*
* @return ChildCreditNoteTypeI18nQuery A secondary query class using the current class as primary query
*/
public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinI18n($locale, $relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNoteTypeI18n', '\CreditNote\Model\CreditNoteTypeI18nQuery');
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(CreditNoteTypeTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(CreditNoteTypeTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(CreditNoteTypeTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(CreditNoteTypeTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(CreditNoteTypeTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildCreditNoteTypeQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(CreditNoteTypeTableMap::CREATED_AT);
}
} // CreditNoteTypeQuery

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,774 @@
<?php
namespace CreditNote\Model\Base;
use \Exception;
use \PDO;
use CreditNote\Model\OrderCreditNote as ChildOrderCreditNote;
use CreditNote\Model\OrderCreditNoteQuery as ChildOrderCreditNoteQuery;
use CreditNote\Model\Map\OrderCreditNoteTableMap;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria;
use Propel\Runtime\ActiveQuery\ModelJoin;
use Propel\Runtime\Collection\Collection;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\Order;
/**
* Base class that represents a query for the 'order_credit_note' table.
*
*
*
* @method ChildOrderCreditNoteQuery orderByOrderId($order = Criteria::ASC) Order by the order_id column
* @method ChildOrderCreditNoteQuery orderByCreditNoteId($order = Criteria::ASC) Order by the credit_note_id column
* @method ChildOrderCreditNoteQuery orderByAmountPrice($order = Criteria::ASC) Order by the amount_price column
* @method ChildOrderCreditNoteQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildOrderCreditNoteQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildOrderCreditNoteQuery groupByOrderId() Group by the order_id column
* @method ChildOrderCreditNoteQuery groupByCreditNoteId() Group by the credit_note_id column
* @method ChildOrderCreditNoteQuery groupByAmountPrice() Group by the amount_price column
* @method ChildOrderCreditNoteQuery groupByCreatedAt() Group by the created_at column
* @method ChildOrderCreditNoteQuery groupByUpdatedAt() Group by the updated_at column
*
* @method ChildOrderCreditNoteQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildOrderCreditNoteQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ChildOrderCreditNoteQuery innerJoin($relation) Adds a INNER JOIN clause to the query
*
* @method ChildOrderCreditNoteQuery leftJoinOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the Order relation
* @method ChildOrderCreditNoteQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
* @method ChildOrderCreditNoteQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
*
* @method ChildOrderCreditNoteQuery leftJoinCreditNote($relationAlias = null) Adds a LEFT JOIN clause to the query using the CreditNote relation
* @method ChildOrderCreditNoteQuery rightJoinCreditNote($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CreditNote relation
* @method ChildOrderCreditNoteQuery innerJoinCreditNote($relationAlias = null) Adds a INNER JOIN clause to the query using the CreditNote relation
*
* @method ChildOrderCreditNote findOne(ConnectionInterface $con = null) Return the first ChildOrderCreditNote matching the query
* @method ChildOrderCreditNote findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderCreditNote matching the query, or a new ChildOrderCreditNote object populated from the query conditions when no match is found
*
* @method ChildOrderCreditNote findOneByOrderId(int $order_id) Return the first ChildOrderCreditNote filtered by the order_id column
* @method ChildOrderCreditNote findOneByCreditNoteId(int $credit_note_id) Return the first ChildOrderCreditNote filtered by the credit_note_id column
* @method ChildOrderCreditNote findOneByAmountPrice(string $amount_price) Return the first ChildOrderCreditNote filtered by the amount_price column
* @method ChildOrderCreditNote findOneByCreatedAt(string $created_at) Return the first ChildOrderCreditNote filtered by the created_at column
* @method ChildOrderCreditNote findOneByUpdatedAt(string $updated_at) Return the first ChildOrderCreditNote filtered by the updated_at column
*
* @method array findByOrderId(int $order_id) Return ChildOrderCreditNote objects filtered by the order_id column
* @method array findByCreditNoteId(int $credit_note_id) Return ChildOrderCreditNote objects filtered by the credit_note_id column
* @method array findByAmountPrice(string $amount_price) Return ChildOrderCreditNote objects filtered by the amount_price column
* @method array findByCreatedAt(string $created_at) Return ChildOrderCreditNote objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildOrderCreditNote objects filtered by the updated_at column
*
*/
abstract class OrderCreditNoteQuery extends ModelCriteria
{
/**
* Initializes internal state of \CreditNote\Model\Base\OrderCreditNoteQuery object.
*
* @param string $dbName The database name
* @param string $modelName The phpName of a model, e.g. 'Book'
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = 'thelia', $modelName = '\\CreditNote\\Model\\OrderCreditNote', $modelAlias = null)
{
parent::__construct($dbName, $modelName, $modelAlias);
}
/**
* Returns a new ChildOrderCreditNoteQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param Criteria $criteria Optional Criteria to build the query from
*
* @return ChildOrderCreditNoteQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof \CreditNote\Model\OrderCreditNoteQuery) {
return $criteria;
}
$query = new \CreditNote\Model\OrderCreditNoteQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
/**
* Find object by primary key.
* Propel uses the instance pool to skip the database if the object exists.
* Go fast if the query is untouched.
*
* <code>
* $obj = $c->findPk(array(12, 34), $con);
* </code>
*
* @param array[$order_id, $credit_note_id] $key Primary key to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ChildOrderCreditNote|array|mixed the result, formatted by the current formatter
*/
public function findPk($key, $con = null)
{
if ($key === null) {
return null;
}
if ((null !== ($obj = OrderCreditNoteTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
// the object is already in the instance pool
return $obj;
}
if ($con === null) {
$con = Propel::getServiceContainer()->getReadConnection(OrderCreditNoteTableMap::DATABASE_NAME);
}
$this->basePreSelect($con);
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|| $this->map || $this->having || $this->joins) {
return $this->findPkComplex($key, $con);
} else {
return $this->findPkSimple($key, $con);
}
}
/**
* Find object by primary key using raw SQL to go fast.
* Bypass doSelect() and the object formatter by using generated code.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildOrderCreditNote A model object, or null if the key is not found
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ORDER_ID, CREDIT_NOTE_ID, AMOUNT_PRICE, CREATED_AT, UPDATED_AT FROM order_credit_note WHERE ORDER_ID = :p0 AND CREDIT_NOTE_ID = :p1';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
}
$obj = null;
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
$obj = new ChildOrderCreditNote();
$obj->hydrate($row);
OrderCreditNoteTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
}
$stmt->closeCursor();
return $obj;
}
/**
* Find object by primary key.
*
* @param mixed $key Primary key to use for the query
* @param ConnectionInterface $con A connection object
*
* @return ChildOrderCreditNote|array|mixed the result, formatted by the current formatter
*/
protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
}
/**
* Find objects by primary key
* <code>
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
* </code>
* @param array $keys Primary keys to use for the query
* @param ConnectionInterface $con an optional connection object
*
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
*/
public function findPks($keys, $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$dataFetcher = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
}
/**
* Filter the query by primary key
*
* @param mixed $key Primary key to use for the query
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function filterByPrimaryKey($key)
{
$this->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $key[0], Criteria::EQUAL);
$this->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $key[1], Criteria::EQUAL);
return $this;
}
/**
* Filter the query by a list of primary keys
*
* @param array $keys The list of primary key to use for the query
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function filterByPrimaryKeys($keys)
{
if (empty($keys)) {
return $this->add(null, '1<>1', Criteria::CUSTOM);
}
foreach ($keys as $key) {
$cton0 = $this->getNewCriterion(OrderCreditNoteTableMap::ORDER_ID, $key[0], Criteria::EQUAL);
$cton1 = $this->getNewCriterion(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $key[1], Criteria::EQUAL);
$cton0->addAnd($cton1);
$this->addOr($cton0);
}
return $this;
}
/**
* Filter the query on the order_id column
*
* Example usage:
* <code>
* $query->filterByOrderId(1234); // WHERE order_id = 1234
* $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
* $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
* </code>
*
* @see filterByOrder()
*
* @param mixed $orderId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function filterByOrderId($orderId = null, $comparison = null)
{
if (is_array($orderId)) {
$useMinMax = false;
if (isset($orderId['min'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($orderId['max'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $orderId, $comparison);
}
/**
* Filter the query on the credit_note_id column
*
* Example usage:
* <code>
* $query->filterByCreditNoteId(1234); // WHERE credit_note_id = 1234
* $query->filterByCreditNoteId(array(12, 34)); // WHERE credit_note_id IN (12, 34)
* $query->filterByCreditNoteId(array('min' => 12)); // WHERE credit_note_id > 12
* </code>
*
* @see filterByCreditNote()
*
* @param mixed $creditNoteId The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function filterByCreditNoteId($creditNoteId = null, $comparison = null)
{
if (is_array($creditNoteId)) {
$useMinMax = false;
if (isset($creditNoteId['min'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($creditNoteId['max'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNoteId, $comparison);
}
/**
* Filter the query on the amount_price column
*
* Example usage:
* <code>
* $query->filterByAmountPrice(1234); // WHERE amount_price = 1234
* $query->filterByAmountPrice(array(12, 34)); // WHERE amount_price IN (12, 34)
* $query->filterByAmountPrice(array('min' => 12)); // WHERE amount_price > 12
* </code>
*
* @param mixed $amountPrice The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function filterByAmountPrice($amountPrice = null, $comparison = null)
{
if (is_array($amountPrice)) {
$useMinMax = false;
if (isset($amountPrice['min'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::AMOUNT_PRICE, $amountPrice['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($amountPrice['max'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::AMOUNT_PRICE, $amountPrice['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderCreditNoteTableMap::AMOUNT_PRICE, $amountPrice, $comparison);
}
/**
* Filter the query on the created_at column
*
* Example usage:
* <code>
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
* </code>
*
* @param mixed $createdAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function filterByCreatedAt($createdAt = null, $comparison = null)
{
if (is_array($createdAt)) {
$useMinMax = false;
if (isset($createdAt['min'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($createdAt['max'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderCreditNoteTableMap::CREATED_AT, $createdAt, $comparison);
}
/**
* Filter the query on the updated_at column
*
* Example usage:
* <code>
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
* </code>
*
* @param mixed $updatedAt The value to use as filter.
* Values can be integers (unix timestamps), DateTime objects, or strings.
* Empty strings are treated as NULL.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
{
if (is_array($updatedAt)) {
$useMinMax = false;
if (isset($updatedAt['min'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($updatedAt['max'])) {
$this->addUsingAlias(OrderCreditNoteTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderCreditNoteTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\Order object
*
* @param \Thelia\Model\Order|ObjectCollection $order The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function filterByOrder($order, $comparison = null)
{
if ($order instanceof \Thelia\Model\Order) {
return $this
->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $order->getId(), $comparison);
} elseif ($order instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(OrderCreditNoteTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection');
}
}
/**
* Adds a JOIN clause to the query using the Order relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('Order');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'Order');
}
return $this;
}
/**
* Use the Order relation Order object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
*/
public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinOrder($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
}
/**
* Filter the query by a related \CreditNote\Model\CreditNote object
*
* @param \CreditNote\Model\CreditNote|ObjectCollection $creditNote The related object(s) to use as filter
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function filterByCreditNote($creditNote, $comparison = null)
{
if ($creditNote instanceof \CreditNote\Model\CreditNote) {
return $this
->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNote->getId(), $comparison);
} elseif ($creditNote instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $creditNote->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCreditNote() only accepts arguments of type \CreditNote\Model\CreditNote or Collection');
}
}
/**
* Adds a JOIN clause to the query using the CreditNote relation
*
* @param string $relationAlias optional alias for the relation
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function joinCreditNote($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('CreditNote');
// create a ModelJoin object for this join
$join = new ModelJoin();
$join->setJoinType($joinType);
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
if ($previousJoin = $this->getPreviousJoin()) {
$join->setPreviousJoin($previousJoin);
}
// add the ModelJoin to the current object
if ($relationAlias) {
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
$this->addJoinObject($join, $relationAlias);
} else {
$this->addJoinObject($join, 'CreditNote');
}
return $this;
}
/**
* Use the CreditNote relation CreditNote object
*
* @see useQuery()
*
* @param string $relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return \CreditNote\Model\CreditNoteQuery A secondary query class using the current class as primary query
*/
public function useCreditNoteQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCreditNote($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'CreditNote', '\CreditNote\Model\CreditNoteQuery');
}
/**
* Exclude object from result
*
* @param ChildOrderCreditNote $orderCreditNote Object to remove from the list of results
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function prune($orderCreditNote = null)
{
if ($orderCreditNote) {
$this->addCond('pruneCond0', $this->getAliasedColName(OrderCreditNoteTableMap::ORDER_ID), $orderCreditNote->getOrderId(), Criteria::NOT_EQUAL);
$this->addCond('pruneCond1', $this->getAliasedColName(OrderCreditNoteTableMap::CREDIT_NOTE_ID), $orderCreditNote->getCreditNoteId(), Criteria::NOT_EQUAL);
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
}
return $this;
}
/**
* Deletes all rows from the order_credit_note table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public function doDeleteAll(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
$affectedRows += parent::doDeleteAll($con);
// Because this db requires some delete cascade/set null emulation, we have to
// clear the cached instance *after* the emulation has happened (since
// instances get re-added by the select statement contained therein).
OrderCreditNoteTableMap::clearInstancePool();
OrderCreditNoteTableMap::clearRelatedInstancePool();
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
}
/**
* Performs a DELETE on the database, given a ChildOrderCreditNote or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or ChildOrderCreditNote object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public function delete(ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
}
$criteria = $this;
// Set the correct dbName
$criteria->setDbName(OrderCreditNoteTableMap::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->beginTransaction();
OrderCreditNoteTableMap::removeInstanceFromPool($criteria);
$affectedRows += ModelCriteria::delete($con);
OrderCreditNoteTableMap::clearRelatedInstancePool();
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
}
// timestampable behavior
/**
* Filter by the latest updated
*
* @param int $nbDays Maximum age of the latest update in days
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function recentlyUpdated($nbDays = 7)
{
return $this->addUsingAlias(OrderCreditNoteTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Filter by the latest created
*
* @param int $nbDays Maximum age of in days
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function recentlyCreated($nbDays = 7)
{
return $this->addUsingAlias(OrderCreditNoteTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
}
/**
* Order by update date desc
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function lastUpdatedFirst()
{
return $this->addDescendingOrderByColumn(OrderCreditNoteTableMap::UPDATED_AT);
}
/**
* Order by update date asc
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function firstUpdatedFirst()
{
return $this->addAscendingOrderByColumn(OrderCreditNoteTableMap::UPDATED_AT);
}
/**
* Order by create date desc
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function lastCreatedFirst()
{
return $this->addDescendingOrderByColumn(OrderCreditNoteTableMap::CREATED_AT);
}
/**
* Order by create date asc
*
* @return ChildOrderCreditNoteQuery The current query, for fluid interface
*/
public function firstCreatedFirst()
{
return $this->addAscendingOrderByColumn(OrderCreditNoteTableMap::CREATED_AT);
}
} // OrderCreditNoteQuery

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CartCreditNote as BaseCartCreditNote;
class CartCreditNote extends BaseCartCreditNote
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CartCreditNoteQuery as BaseCartCreditNoteQuery;
/**
* Skeleton subclass for performing query and update operations on the 'cart_credit_note' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CartCreditNoteQuery extends BaseCartCreditNoteQuery
{
} // CartCreditNoteQuery

View File

@@ -0,0 +1,129 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNote as BaseCreditNote;
use CreditNote\Model\CreditNoteStatus as ChildCreditNoteStatus;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\Currency;
use Thelia\Model\Customer;
use Thelia\Model\Order;
class CreditNote extends BaseCreditNote
{
use \CreditNote\Model\Tools\ModelEventDispatcherTrait;
/**
* Declares an association between this object and a ChildOrder object.
*
* @param Order $v
* @return \CreditNote\Model\CreditNote The current object (for fluent API support)
* @throws PropelException
*/
public function setOrder(Order $v = null)
{
if ($v === null) {
$this->setOrderId(null);
} else {
$this->setOrderId($v->getId());
}
$this->aOrder = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomer object, it will not be re-added.
if (method_exists($v, 'addCreditNote') && $v !== null) {
$v->addCreditNote($this);
}
return $this;
}
/**
* Declares an association between this object and a ChildCurrency object.
*
* @param Currency $v
* @return \CreditNote\Model\CreditNote The current object (for fluent API support)
* @throws PropelException
*/
public function setCurrency(Currency $v = null)
{
if ($v === null) {
$this->setCurrencyId(null);
} else {
$this->setCurrencyId($v->getId());
}
$this->aCurrency = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomer object, it will not be re-added.
if (method_exists($v, 'addCreditNote') && $v !== null) {
$v->addCreditNote($this);
}
return $this;
}
/**
* Declares an association between this object and a ChildCustomer object.
*
* @param Customer $v
* @return \CreditNote\Model\CreditNote The current object (for fluent API support)
* @throws PropelException
*/
public function setCustomer(Customer $v = null)
{
if ($v === null) {
$this->setCustomerId(null);
} else {
$this->setCustomerId($v->getId());
}
$this->aCustomer = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomer object, it will not be re-added.
if (method_exists($v, 'addCreditNote') && $v !== null) {
$v->addCreditNote($this);
}
return $this;
}
public function setStatusId($v)
{
// check status flow
if (null !== $this->getStatusId() && (int) $v !== (int) $this->getStatusId()) {
if (!CreditNoteStatusFlowQuery::create()
->filterByFromStatusId($this->getStatusId())
->filterByToStatusId($v)
->findOne()) {
throw new \Exception('You do not respect the status flow');
}
}
return parent::setStatusId($v);
}
public function setCreditNoteStatus(ChildCreditNoteStatus $v = null)
{
// check status flow
if (null !== $v && null !== $this->getCreditNoteStatus() && (int) $v->getId() !== (int) $this->getCreditNoteStatus()->getId()) {
if (!CreditNoteStatusFlowQuery::create()
->filterByFromStatusId($this->getCreditNoteStatus()->getId())
->filterByToStatusId($v->getId())
->findOne()) {
throw new \Exception('You do not respect the status flow');
}
}
return parent::setCreditNoteStatus($v);
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteAddress as BaseCreditNoteAddress;
class CreditNoteAddress extends BaseCreditNoteAddress
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteAddressQuery as BaseCreditNoteAddressQuery;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note_address' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteAddressQuery extends BaseCreditNoteAddressQuery
{
} // CreditNoteAddressQuery

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteComment as BaseCreditNoteComment;
class CreditNoteComment extends BaseCreditNoteComment
{
use \CreditNote\Model\Tools\ModelEventDispatcherTrait;
}

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteCommentQuery as BaseCreditNoteCommentQuery;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note_comment' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteCommentQuery extends BaseCreditNoteCommentQuery
{
} // CreditNoteCommentQuery

View File

@@ -0,0 +1,38 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteDetail as BaseCreditNoteDetail;
use Propel\Runtime\Exception\PropelException;
use Thelia\Model\OrderProduct;
class CreditNoteDetail extends BaseCreditNoteDetail
{
use \CreditNote\Model\Tools\ModelEventDispatcherTrait;
/**
* Declares an association between this object and a ChildOrderProduct object.
*
* @param OrderProduct $v
* @return \CreditNote\Model\CreditNoteDetail The current object (for fluent API support)
* @throws PropelException
*/
public function setOrderProduct(OrderProduct $v = null)
{
if ($v === null) {
$this->setOrderProductId(null);
} else {
$this->setOrderProductId($v->getId());
}
$this->aOrderProduct = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomer object, it will not be re-added.
if (method_exists($v, 'addCreditNote') && $v !== null) {
$v->addCreditNote($this);
}
return $this;
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteDetailQuery as BaseCreditNoteDetailQuery;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note_detail' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteDetailQuery extends BaseCreditNoteDetailQuery
{
} // CreditNoteDetailQuery

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteQuery as BaseCreditNoteQuery;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteQuery extends BaseCreditNoteQuery
{
} // CreditNoteQuery

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteStatus as BaseCreditNoteStatus;
class CreditNoteStatus extends BaseCreditNoteStatus
{
use \CreditNote\Model\Tools\ModelEventDispatcherTrait;
}

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteStatusFlow as BaseCreditNoteStatusFlow;
class CreditNoteStatusFlow extends BaseCreditNoteStatusFlow
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteStatusFlowQuery as BaseCreditNoteStatusFlowQuery;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note_status_flow' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteStatusFlowQuery extends BaseCreditNoteStatusFlowQuery
{
} // CreditNoteStatusFlowQuery

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteStatusI18n as BaseCreditNoteStatusI18n;
class CreditNoteStatusI18n extends BaseCreditNoteStatusI18n
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteStatusI18nQuery as BaseCreditNoteStatusI18nQuery;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note_status_i18n' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteStatusI18nQuery extends BaseCreditNoteStatusI18nQuery
{
} // CreditNoteStatusI18nQuery

View File

@@ -0,0 +1,63 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteStatusQuery as BaseCreditNoteStatusQuery;
use Propel\Runtime\ActiveQuery\Criteria;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note_status' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteStatusQuery extends BaseCreditNoteStatusQuery
{
/**
* @param CreditNoteStatus $creditNoteStatus
* @return CreditNoteStatus|null
*/
public static function findNextCreditNoteUsedStatus(CreditNoteStatus $creditNoteStatus)
{
/** @var CreditNoteStatusFlow $statusFlow */
$statusFlow = CreditNoteStatusFlowQuery::create()
->filterByFromStatusId($creditNoteStatus->getId())
->orderByPriority(Criteria::ASC)
->useCreditNoteStatusRelatedByToStatusIdQuery()
->filterByUsed(true)
->endUse()
->findOne();
if (null === $statusFlow) {
return null;
}
return $statusFlow->getCreditNoteStatusRelatedByToStatusId();
}
/**
* @param CreditNoteStatus $creditNoteStatus
* @return CreditNoteStatus|null
*/
public static function findNextCreditNoteStatus(CreditNoteStatus $creditNoteStatus)
{
/** @var CreditNoteStatusFlow $statusFlow */
$statusFlow = CreditNoteStatusFlowQuery::create()
->filterByFromStatusId($creditNoteStatus->getId())
->orderByPriority(Criteria::ASC)
->useCreditNoteStatusRelatedByToStatusIdQuery()
->filterByUsed($creditNoteStatus->getUsed())
->endUse()
->findOne();
if (null === $statusFlow) {
return null;
}
return $statusFlow->getCreditNoteStatusRelatedByToStatusId();
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteType as BaseCreditNoteType;
class CreditNoteType extends BaseCreditNoteType
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteTypeI18n as BaseCreditNoteTypeI18n;
class CreditNoteTypeI18n extends BaseCreditNoteTypeI18n
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteTypeI18nQuery as BaseCreditNoteTypeI18nQuery;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note_type_i18n' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteTypeI18nQuery extends BaseCreditNoteTypeI18nQuery
{
} // CreditNoteTypeI18nQuery

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteTypeQuery as BaseCreditNoteTypeQuery;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note_type' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteTypeQuery extends BaseCreditNoteTypeQuery
{
} // CreditNoteTypeQuery

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteVersion as BaseCreditNoteVersion;
class CreditNoteVersion extends BaseCreditNoteVersion
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\CreditNoteVersionQuery as BaseCreditNoteVersionQuery;
/**
* Skeleton subclass for performing query and update operations on the 'credit_note_version' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class CreditNoteVersionQuery extends BaseCreditNoteVersionQuery
{
} // CreditNoteVersionQuery

View File

@@ -0,0 +1,504 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CartCreditNote;
use CreditNote\Model\CartCreditNoteQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'cart_credit_note' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CartCreditNoteTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CartCreditNoteTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'cart_credit_note';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CartCreditNote';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CartCreditNote';
/**
* The total number of columns
*/
const NUM_COLUMNS = 5;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 5;
/**
* the column name for the CART_ID field
*/
const CART_ID = 'cart_credit_note.CART_ID';
/**
* the column name for the CREDIT_NOTE_ID field
*/
const CREDIT_NOTE_ID = 'cart_credit_note.CREDIT_NOTE_ID';
/**
* the column name for the AMOUNT_PRICE field
*/
const AMOUNT_PRICE = 'cart_credit_note.AMOUNT_PRICE';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'cart_credit_note.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'cart_credit_note.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('CartId', 'CreditNoteId', 'AmountPrice', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('cartId', 'creditNoteId', 'amountPrice', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CartCreditNoteTableMap::CART_ID, CartCreditNoteTableMap::CREDIT_NOTE_ID, CartCreditNoteTableMap::AMOUNT_PRICE, CartCreditNoteTableMap::CREATED_AT, CartCreditNoteTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('CART_ID', 'CREDIT_NOTE_ID', 'AMOUNT_PRICE', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('cart_id', 'credit_note_id', 'amount_price', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('CartId' => 0, 'CreditNoteId' => 1, 'AmountPrice' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
self::TYPE_STUDLYPHPNAME => array('cartId' => 0, 'creditNoteId' => 1, 'amountPrice' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
self::TYPE_COLNAME => array(CartCreditNoteTableMap::CART_ID => 0, CartCreditNoteTableMap::CREDIT_NOTE_ID => 1, CartCreditNoteTableMap::AMOUNT_PRICE => 2, CartCreditNoteTableMap::CREATED_AT => 3, CartCreditNoteTableMap::UPDATED_AT => 4, ),
self::TYPE_RAW_COLNAME => array('CART_ID' => 0, 'CREDIT_NOTE_ID' => 1, 'AMOUNT_PRICE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
self::TYPE_FIELDNAME => array('cart_id' => 0, 'credit_note_id' => 1, 'amount_price' => 2, 'created_at' => 3, 'updated_at' => 4, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('cart_credit_note');
$this->setPhpName('CartCreditNote');
$this->setClassName('\\CreditNote\\Model\\CartCreditNote');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('CART_ID', 'CartId', 'INTEGER' , 'cart', 'ID', true, null, null);
$this->addForeignPrimaryKey('CREDIT_NOTE_ID', 'CreditNoteId', 'INTEGER' , 'credit_note', 'ID', true, null, null);
$this->addColumn('AMOUNT_PRICE', 'AmountPrice', 'DECIMAL', false, 16, 0);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('Cart', '\\Thelia\\Model\\Cart', RelationMap::MANY_TO_ONE, array('cart_id' => 'id', ), 'CASCADE', 'RESTRICT');
$this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('credit_note_id' => 'id', ), 'CASCADE', 'RESTRICT');
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by find*()
* and findPk*() calls.
*
* @param \CreditNote\Model\CartCreditNote $obj A \CreditNote\Model\CartCreditNote object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool($obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if (null === $key) {
$key = serialize(array((string) $obj->getCartId(), (string) $obj->getCreditNoteId()));
} // if key === null
self::$instances[$key] = $obj;
}
}
/**
* Removes an object from the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doDelete
* methods in your stub classes -- you may need to explicitly remove objects
* from the cache in order to prevent returning objects that no longer exist.
*
* @param mixed $value A \CreditNote\Model\CartCreditNote object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && null !== $value) {
if (is_object($value) && $value instanceof \CreditNote\Model\CartCreditNote) {
$key = serialize(array((string) $value->getCartId(), (string) $value->getCreditNoteId()));
} elseif (is_array($value) && count($value) === 2) {
// assume we've been passed a primary key";
$key = serialize(array((string) $value[0], (string) $value[1]));
} elseif ($value instanceof Criteria) {
self::$instances = [];
return;
} else {
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\CartCreditNote object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
throw $e;
}
unset(self::$instances[$key]);
}
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('CartId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('CartId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)]));
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return $pks;
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CartCreditNoteTableMap::CLASS_DEFAULT : CartCreditNoteTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CartCreditNote object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CartCreditNoteTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CartCreditNoteTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CartCreditNoteTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CartCreditNoteTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CartCreditNoteTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CartCreditNoteTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CartCreditNoteTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CartCreditNoteTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CartCreditNoteTableMap::CART_ID);
$criteria->addSelectColumn(CartCreditNoteTableMap::CREDIT_NOTE_ID);
$criteria->addSelectColumn(CartCreditNoteTableMap::AMOUNT_PRICE);
$criteria->addSelectColumn(CartCreditNoteTableMap::CREATED_AT);
$criteria->addSelectColumn(CartCreditNoteTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.CART_ID');
$criteria->addSelectColumn($alias . '.CREDIT_NOTE_ID');
$criteria->addSelectColumn($alias . '.AMOUNT_PRICE');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CartCreditNoteTableMap::DATABASE_NAME)->getTable(CartCreditNoteTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CartCreditNoteTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CartCreditNoteTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CartCreditNoteTableMap());
}
}
/**
* Performs a DELETE on the database, given a CartCreditNote or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CartCreditNote object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CartCreditNote) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CartCreditNoteTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(CartCreditNoteTableMap::CART_ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(CartCreditNoteTableMap::CREDIT_NOTE_ID, $value[1]));
$criteria->addOr($criterion);
}
}
$query = CartCreditNoteQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CartCreditNoteTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CartCreditNoteTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the cart_credit_note table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CartCreditNoteQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CartCreditNote or Criteria object.
*
* @param mixed $criteria Criteria or CartCreditNote object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CartCreditNoteTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CartCreditNote object
}
// Set the correct dbName
$query = CartCreditNoteQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CartCreditNoteTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CartCreditNoteTableMap::buildTableMap();

View File

@@ -0,0 +1,539 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNoteAddress;
use CreditNote\Model\CreditNoteAddressQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note_address' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteAddressTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteAddressTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note_address';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNoteAddress';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNoteAddress';
/**
* The total number of columns
*/
const NUM_COLUMNS = 16;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 16;
/**
* the column name for the ID field
*/
const ID = 'credit_note_address.ID';
/**
* the column name for the CUSTOMER_TITLE_ID field
*/
const CUSTOMER_TITLE_ID = 'credit_note_address.CUSTOMER_TITLE_ID';
/**
* the column name for the COMPANY field
*/
const COMPANY = 'credit_note_address.COMPANY';
/**
* the column name for the FIRSTNAME field
*/
const FIRSTNAME = 'credit_note_address.FIRSTNAME';
/**
* the column name for the LASTNAME field
*/
const LASTNAME = 'credit_note_address.LASTNAME';
/**
* the column name for the ADDRESS1 field
*/
const ADDRESS1 = 'credit_note_address.ADDRESS1';
/**
* the column name for the ADDRESS2 field
*/
const ADDRESS2 = 'credit_note_address.ADDRESS2';
/**
* the column name for the ADDRESS3 field
*/
const ADDRESS3 = 'credit_note_address.ADDRESS3';
/**
* the column name for the ZIPCODE field
*/
const ZIPCODE = 'credit_note_address.ZIPCODE';
/**
* the column name for the CITY field
*/
const CITY = 'credit_note_address.CITY';
/**
* the column name for the PHONE field
*/
const PHONE = 'credit_note_address.PHONE';
/**
* the column name for the CELLPHONE field
*/
const CELLPHONE = 'credit_note_address.CELLPHONE';
/**
* the column name for the COUNTRY_ID field
*/
const COUNTRY_ID = 'credit_note_address.COUNTRY_ID';
/**
* the column name for the STATE_ID field
*/
const STATE_ID = 'credit_note_address.STATE_ID';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'credit_note_address.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'credit_note_address.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'Phone', 'Cellphone', 'CountryId', 'StateId', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'cellphone', 'countryId', 'stateId', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CreditNoteAddressTableMap::ID, CreditNoteAddressTableMap::CUSTOMER_TITLE_ID, CreditNoteAddressTableMap::COMPANY, CreditNoteAddressTableMap::FIRSTNAME, CreditNoteAddressTableMap::LASTNAME, CreditNoteAddressTableMap::ADDRESS1, CreditNoteAddressTableMap::ADDRESS2, CreditNoteAddressTableMap::ADDRESS3, CreditNoteAddressTableMap::ZIPCODE, CreditNoteAddressTableMap::CITY, CreditNoteAddressTableMap::PHONE, CreditNoteAddressTableMap::CELLPHONE, CreditNoteAddressTableMap::COUNTRY_ID, CreditNoteAddressTableMap::STATE_ID, CreditNoteAddressTableMap::CREATED_AT, CreditNoteAddressTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'PHONE', 'CELLPHONE', 'COUNTRY_ID', 'STATE_ID', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'cellphone', 'country_id', 'state_id', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'CustomerTitleId' => 1, 'Company' => 2, 'Firstname' => 3, 'Lastname' => 4, 'Address1' => 5, 'Address2' => 6, 'Address3' => 7, 'Zipcode' => 8, 'City' => 9, 'Phone' => 10, 'Cellphone' => 11, 'CountryId' => 12, 'StateId' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'customerTitleId' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'cellphone' => 11, 'countryId' => 12, 'stateId' => 13, 'createdAt' => 14, 'updatedAt' => 15, ),
self::TYPE_COLNAME => array(CreditNoteAddressTableMap::ID => 0, CreditNoteAddressTableMap::CUSTOMER_TITLE_ID => 1, CreditNoteAddressTableMap::COMPANY => 2, CreditNoteAddressTableMap::FIRSTNAME => 3, CreditNoteAddressTableMap::LASTNAME => 4, CreditNoteAddressTableMap::ADDRESS1 => 5, CreditNoteAddressTableMap::ADDRESS2 => 6, CreditNoteAddressTableMap::ADDRESS3 => 7, CreditNoteAddressTableMap::ZIPCODE => 8, CreditNoteAddressTableMap::CITY => 9, CreditNoteAddressTableMap::PHONE => 10, CreditNoteAddressTableMap::CELLPHONE => 11, CreditNoteAddressTableMap::COUNTRY_ID => 12, CreditNoteAddressTableMap::STATE_ID => 13, CreditNoteAddressTableMap::CREATED_AT => 14, CreditNoteAddressTableMap::UPDATED_AT => 15, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CUSTOMER_TITLE_ID' => 1, 'COMPANY' => 2, 'FIRSTNAME' => 3, 'LASTNAME' => 4, 'ADDRESS1' => 5, 'ADDRESS2' => 6, 'ADDRESS3' => 7, 'ZIPCODE' => 8, 'CITY' => 9, 'PHONE' => 10, 'CELLPHONE' => 11, 'COUNTRY_ID' => 12, 'STATE_ID' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, ),
self::TYPE_FIELDNAME => array('id' => 0, 'customer_title_id' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'cellphone' => 11, 'country_id' => 12, 'state_id' => 13, 'created_at' => 14, 'updated_at' => 15, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note_address');
$this->setPhpName('CreditNoteAddress');
$this->setClassName('\\CreditNote\\Model\\CreditNoteAddress');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
$this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
$this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null);
$this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', false, 255, null);
$this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', false, 255, null);
$this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null);
$this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
$this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
$this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null);
$this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', true, null, null);
$this->addForeignKey('STATE_ID', 'StateId', 'INTEGER', 'state', 'ID', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('State', '\\Thelia\\Model\\State', RelationMap::MANY_TO_ONE, array('state_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::ONE_TO_MANY, array('id' => 'invoice_address_id', ), 'RESTRICT', 'RESTRICT', 'CreditNotes');
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteAddressTableMap::CLASS_DEFAULT : CreditNoteAddressTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNoteAddress object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteAddressTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteAddressTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteAddressTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteAddressTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteAddressTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteAddressTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteAddressTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteAddressTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteAddressTableMap::ID);
$criteria->addSelectColumn(CreditNoteAddressTableMap::CUSTOMER_TITLE_ID);
$criteria->addSelectColumn(CreditNoteAddressTableMap::COMPANY);
$criteria->addSelectColumn(CreditNoteAddressTableMap::FIRSTNAME);
$criteria->addSelectColumn(CreditNoteAddressTableMap::LASTNAME);
$criteria->addSelectColumn(CreditNoteAddressTableMap::ADDRESS1);
$criteria->addSelectColumn(CreditNoteAddressTableMap::ADDRESS2);
$criteria->addSelectColumn(CreditNoteAddressTableMap::ADDRESS3);
$criteria->addSelectColumn(CreditNoteAddressTableMap::ZIPCODE);
$criteria->addSelectColumn(CreditNoteAddressTableMap::CITY);
$criteria->addSelectColumn(CreditNoteAddressTableMap::PHONE);
$criteria->addSelectColumn(CreditNoteAddressTableMap::CELLPHONE);
$criteria->addSelectColumn(CreditNoteAddressTableMap::COUNTRY_ID);
$criteria->addSelectColumn(CreditNoteAddressTableMap::STATE_ID);
$criteria->addSelectColumn(CreditNoteAddressTableMap::CREATED_AT);
$criteria->addSelectColumn(CreditNoteAddressTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
$criteria->addSelectColumn($alias . '.COMPANY');
$criteria->addSelectColumn($alias . '.FIRSTNAME');
$criteria->addSelectColumn($alias . '.LASTNAME');
$criteria->addSelectColumn($alias . '.ADDRESS1');
$criteria->addSelectColumn($alias . '.ADDRESS2');
$criteria->addSelectColumn($alias . '.ADDRESS3');
$criteria->addSelectColumn($alias . '.ZIPCODE');
$criteria->addSelectColumn($alias . '.CITY');
$criteria->addSelectColumn($alias . '.PHONE');
$criteria->addSelectColumn($alias . '.CELLPHONE');
$criteria->addSelectColumn($alias . '.COUNTRY_ID');
$criteria->addSelectColumn($alias . '.STATE_ID');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteAddressTableMap::DATABASE_NAME)->getTable(CreditNoteAddressTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteAddressTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteAddressTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteAddressTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNoteAddress or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNoteAddress object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteAddressTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNoteAddress) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteAddressTableMap::DATABASE_NAME);
$criteria->add(CreditNoteAddressTableMap::ID, (array) $values, Criteria::IN);
}
$query = CreditNoteAddressQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteAddressTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteAddressTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note_address table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteAddressQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNoteAddress or Criteria object.
*
* @param mixed $criteria Criteria or CreditNoteAddress object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteAddressTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteAddress object
}
if ($criteria->containsKey(CreditNoteAddressTableMap::ID) && $criteria->keyContainsValue(CreditNoteAddressTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteAddressTableMap::ID.')');
}
// Set the correct dbName
$query = CreditNoteAddressQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteAddressTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteAddressTableMap::buildTableMap();

View File

@@ -0,0 +1,457 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNoteComment;
use CreditNote\Model\CreditNoteCommentQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note_comment' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteCommentTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteCommentTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note_comment';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNoteComment';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNoteComment';
/**
* The total number of columns
*/
const NUM_COLUMNS = 6;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 6;
/**
* the column name for the ID field
*/
const ID = 'credit_note_comment.ID';
/**
* the column name for the CREDIT_NOTE_ID field
*/
const CREDIT_NOTE_ID = 'credit_note_comment.CREDIT_NOTE_ID';
/**
* the column name for the ADMIN_ID field
*/
const ADMIN_ID = 'credit_note_comment.ADMIN_ID';
/**
* the column name for the COMMENT field
*/
const COMMENT = 'credit_note_comment.COMMENT';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'credit_note_comment.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'credit_note_comment.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'CreditNoteId', 'AdminId', 'Comment', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'creditNoteId', 'adminId', 'comment', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CreditNoteCommentTableMap::ID, CreditNoteCommentTableMap::CREDIT_NOTE_ID, CreditNoteCommentTableMap::ADMIN_ID, CreditNoteCommentTableMap::COMMENT, CreditNoteCommentTableMap::CREATED_AT, CreditNoteCommentTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'CREDIT_NOTE_ID', 'ADMIN_ID', 'COMMENT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'credit_note_id', 'admin_id', 'comment', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'CreditNoteId' => 1, 'AdminId' => 2, 'Comment' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'creditNoteId' => 1, 'adminId' => 2, 'comment' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
self::TYPE_COLNAME => array(CreditNoteCommentTableMap::ID => 0, CreditNoteCommentTableMap::CREDIT_NOTE_ID => 1, CreditNoteCommentTableMap::ADMIN_ID => 2, CreditNoteCommentTableMap::COMMENT => 3, CreditNoteCommentTableMap::CREATED_AT => 4, CreditNoteCommentTableMap::UPDATED_AT => 5, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREDIT_NOTE_ID' => 1, 'ADMIN_ID' => 2, 'COMMENT' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
self::TYPE_FIELDNAME => array('id' => 0, 'credit_note_id' => 1, 'admin_id' => 2, 'comment' => 3, 'created_at' => 4, 'updated_at' => 5, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note_comment');
$this->setPhpName('CreditNoteComment');
$this->setClassName('\\CreditNote\\Model\\CreditNoteComment');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('CREDIT_NOTE_ID', 'CreditNoteId', 'INTEGER', 'credit_note', 'ID', true, null, null);
$this->addForeignKey('ADMIN_ID', 'AdminId', 'INTEGER', 'admin', 'ID', false, null, null);
$this->addColumn('COMMENT', 'Comment', 'CLOB', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('credit_note_id' => 'id', ), 'CASCADE', 'RESTRICT');
$this->addRelation('Admin', '\\Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'SET NULL', 'RESTRICT');
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteCommentTableMap::CLASS_DEFAULT : CreditNoteCommentTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNoteComment object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteCommentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteCommentTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteCommentTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteCommentTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteCommentTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteCommentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteCommentTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteCommentTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteCommentTableMap::ID);
$criteria->addSelectColumn(CreditNoteCommentTableMap::CREDIT_NOTE_ID);
$criteria->addSelectColumn(CreditNoteCommentTableMap::ADMIN_ID);
$criteria->addSelectColumn(CreditNoteCommentTableMap::COMMENT);
$criteria->addSelectColumn(CreditNoteCommentTableMap::CREATED_AT);
$criteria->addSelectColumn(CreditNoteCommentTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.CREDIT_NOTE_ID');
$criteria->addSelectColumn($alias . '.ADMIN_ID');
$criteria->addSelectColumn($alias . '.COMMENT');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteCommentTableMap::DATABASE_NAME)->getTable(CreditNoteCommentTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteCommentTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteCommentTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteCommentTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNoteComment or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNoteComment object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNoteComment) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteCommentTableMap::DATABASE_NAME);
$criteria->add(CreditNoteCommentTableMap::ID, (array) $values, Criteria::IN);
}
$query = CreditNoteCommentQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteCommentTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteCommentTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note_comment table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteCommentQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNoteComment or Criteria object.
*
* @param mixed $criteria Criteria or CreditNoteComment object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteCommentTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteComment object
}
if ($criteria->containsKey(CreditNoteCommentTableMap::ID) && $criteria->keyContainsValue(CreditNoteCommentTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteCommentTableMap::ID.')');
}
// Set the correct dbName
$query = CreditNoteCommentQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteCommentTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteCommentTableMap::buildTableMap();

View File

@@ -0,0 +1,498 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNoteDetail;
use CreditNote\Model\CreditNoteDetailQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note_detail' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteDetailTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteDetailTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note_detail';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNoteDetail';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNoteDetail';
/**
* The total number of columns
*/
const NUM_COLUMNS = 11;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 11;
/**
* the column name for the ID field
*/
const ID = 'credit_note_detail.ID';
/**
* the column name for the CREDIT_NOTE_ID field
*/
const CREDIT_NOTE_ID = 'credit_note_detail.CREDIT_NOTE_ID';
/**
* the column name for the PRICE field
*/
const PRICE = 'credit_note_detail.PRICE';
/**
* the column name for the PRICE_WITH_TAX field
*/
const PRICE_WITH_TAX = 'credit_note_detail.PRICE_WITH_TAX';
/**
* the column name for the TAX_RULE_ID field
*/
const TAX_RULE_ID = 'credit_note_detail.TAX_RULE_ID';
/**
* the column name for the ORDER_PRODUCT_ID field
*/
const ORDER_PRODUCT_ID = 'credit_note_detail.ORDER_PRODUCT_ID';
/**
* the column name for the TYPE field
*/
const TYPE = 'credit_note_detail.TYPE';
/**
* the column name for the QUANTITY field
*/
const QUANTITY = 'credit_note_detail.QUANTITY';
/**
* the column name for the TITLE field
*/
const TITLE = 'credit_note_detail.TITLE';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'credit_note_detail.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'credit_note_detail.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'CreditNoteId', 'Price', 'PriceWithTax', 'TaxRuleId', 'OrderProductId', 'Type', 'Quantity', 'Title', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'creditNoteId', 'price', 'priceWithTax', 'taxRuleId', 'orderProductId', 'type', 'quantity', 'title', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CreditNoteDetailTableMap::ID, CreditNoteDetailTableMap::CREDIT_NOTE_ID, CreditNoteDetailTableMap::PRICE, CreditNoteDetailTableMap::PRICE_WITH_TAX, CreditNoteDetailTableMap::TAX_RULE_ID, CreditNoteDetailTableMap::ORDER_PRODUCT_ID, CreditNoteDetailTableMap::TYPE, CreditNoteDetailTableMap::QUANTITY, CreditNoteDetailTableMap::TITLE, CreditNoteDetailTableMap::CREATED_AT, CreditNoteDetailTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'CREDIT_NOTE_ID', 'PRICE', 'PRICE_WITH_TAX', 'TAX_RULE_ID', 'ORDER_PRODUCT_ID', 'TYPE', 'QUANTITY', 'TITLE', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'credit_note_id', 'price', 'price_with_tax', 'tax_rule_id', 'order_product_id', 'type', 'quantity', 'title', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'CreditNoteId' => 1, 'Price' => 2, 'PriceWithTax' => 3, 'TaxRuleId' => 4, 'OrderProductId' => 5, 'Type' => 6, 'Quantity' => 7, 'Title' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'creditNoteId' => 1, 'price' => 2, 'priceWithTax' => 3, 'taxRuleId' => 4, 'orderProductId' => 5, 'type' => 6, 'quantity' => 7, 'title' => 8, 'createdAt' => 9, 'updatedAt' => 10, ),
self::TYPE_COLNAME => array(CreditNoteDetailTableMap::ID => 0, CreditNoteDetailTableMap::CREDIT_NOTE_ID => 1, CreditNoteDetailTableMap::PRICE => 2, CreditNoteDetailTableMap::PRICE_WITH_TAX => 3, CreditNoteDetailTableMap::TAX_RULE_ID => 4, CreditNoteDetailTableMap::ORDER_PRODUCT_ID => 5, CreditNoteDetailTableMap::TYPE => 6, CreditNoteDetailTableMap::QUANTITY => 7, CreditNoteDetailTableMap::TITLE => 8, CreditNoteDetailTableMap::CREATED_AT => 9, CreditNoteDetailTableMap::UPDATED_AT => 10, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREDIT_NOTE_ID' => 1, 'PRICE' => 2, 'PRICE_WITH_TAX' => 3, 'TAX_RULE_ID' => 4, 'ORDER_PRODUCT_ID' => 5, 'TYPE' => 6, 'QUANTITY' => 7, 'TITLE' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ),
self::TYPE_FIELDNAME => array('id' => 0, 'credit_note_id' => 1, 'price' => 2, 'price_with_tax' => 3, 'tax_rule_id' => 4, 'order_product_id' => 5, 'type' => 6, 'quantity' => 7, 'title' => 8, 'created_at' => 9, 'updated_at' => 10, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note_detail');
$this->setPhpName('CreditNoteDetail');
$this->setClassName('\\CreditNote\\Model\\CreditNoteDetail');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('CREDIT_NOTE_ID', 'CreditNoteId', 'INTEGER', 'credit_note', 'ID', true, null, null);
$this->addColumn('PRICE', 'Price', 'DECIMAL', false, 16, 0);
$this->addColumn('PRICE_WITH_TAX', 'PriceWithTax', 'DECIMAL', false, 16, 0);
$this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
$this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', false, null, null);
$this->addColumn('TYPE', 'Type', 'VARCHAR', false, 55, null);
$this->addColumn('QUANTITY', 'Quantity', 'INTEGER', true, null, 0);
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('credit_note_id' => 'id', ), 'CASCADE', 'RESTRICT');
$this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'RESTRICT', 'RESTRICT');
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteDetailTableMap::CLASS_DEFAULT : CreditNoteDetailTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNoteDetail object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteDetailTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteDetailTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteDetailTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteDetailTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteDetailTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteDetailTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteDetailTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteDetailTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteDetailTableMap::ID);
$criteria->addSelectColumn(CreditNoteDetailTableMap::CREDIT_NOTE_ID);
$criteria->addSelectColumn(CreditNoteDetailTableMap::PRICE);
$criteria->addSelectColumn(CreditNoteDetailTableMap::PRICE_WITH_TAX);
$criteria->addSelectColumn(CreditNoteDetailTableMap::TAX_RULE_ID);
$criteria->addSelectColumn(CreditNoteDetailTableMap::ORDER_PRODUCT_ID);
$criteria->addSelectColumn(CreditNoteDetailTableMap::TYPE);
$criteria->addSelectColumn(CreditNoteDetailTableMap::QUANTITY);
$criteria->addSelectColumn(CreditNoteDetailTableMap::TITLE);
$criteria->addSelectColumn(CreditNoteDetailTableMap::CREATED_AT);
$criteria->addSelectColumn(CreditNoteDetailTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.CREDIT_NOTE_ID');
$criteria->addSelectColumn($alias . '.PRICE');
$criteria->addSelectColumn($alias . '.PRICE_WITH_TAX');
$criteria->addSelectColumn($alias . '.TAX_RULE_ID');
$criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID');
$criteria->addSelectColumn($alias . '.TYPE');
$criteria->addSelectColumn($alias . '.QUANTITY');
$criteria->addSelectColumn($alias . '.TITLE');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteDetailTableMap::DATABASE_NAME)->getTable(CreditNoteDetailTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteDetailTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteDetailTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteDetailTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNoteDetail or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNoteDetail object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteDetailTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNoteDetail) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteDetailTableMap::DATABASE_NAME);
$criteria->add(CreditNoteDetailTableMap::ID, (array) $values, Criteria::IN);
}
$query = CreditNoteDetailQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteDetailTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteDetailTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note_detail table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteDetailQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNoteDetail or Criteria object.
*
* @param mixed $criteria Criteria or CreditNoteDetail object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteDetailTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteDetail object
}
if ($criteria->containsKey(CreditNoteDetailTableMap::ID) && $criteria->keyContainsValue(CreditNoteDetailTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteDetailTableMap::ID.')');
}
// Set the correct dbName
$query = CreditNoteDetailQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteDetailTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteDetailTableMap::buildTableMap();

View File

@@ -0,0 +1,465 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNoteStatusFlow;
use CreditNote\Model\CreditNoteStatusFlowQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note_status_flow' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteStatusFlowTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteStatusFlowTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note_status_flow';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNoteStatusFlow';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNoteStatusFlow';
/**
* The total number of columns
*/
const NUM_COLUMNS = 7;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 7;
/**
* the column name for the ID field
*/
const ID = 'credit_note_status_flow.ID';
/**
* the column name for the FROM_STATUS_ID field
*/
const FROM_STATUS_ID = 'credit_note_status_flow.FROM_STATUS_ID';
/**
* the column name for the TO_STATUS_ID field
*/
const TO_STATUS_ID = 'credit_note_status_flow.TO_STATUS_ID';
/**
* the column name for the PRIORITY field
*/
const PRIORITY = 'credit_note_status_flow.PRIORITY';
/**
* the column name for the ROOT field
*/
const ROOT = 'credit_note_status_flow.ROOT';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'credit_note_status_flow.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'credit_note_status_flow.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'FromStatusId', 'ToStatusId', 'Priority', 'Root', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'fromStatusId', 'toStatusId', 'priority', 'root', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CreditNoteStatusFlowTableMap::ID, CreditNoteStatusFlowTableMap::FROM_STATUS_ID, CreditNoteStatusFlowTableMap::TO_STATUS_ID, CreditNoteStatusFlowTableMap::PRIORITY, CreditNoteStatusFlowTableMap::ROOT, CreditNoteStatusFlowTableMap::CREATED_AT, CreditNoteStatusFlowTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'FROM_STATUS_ID', 'TO_STATUS_ID', 'PRIORITY', 'ROOT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'from_status_id', 'to_status_id', 'priority', 'root', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'FromStatusId' => 1, 'ToStatusId' => 2, 'Priority' => 3, 'Root' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'fromStatusId' => 1, 'toStatusId' => 2, 'priority' => 3, 'root' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
self::TYPE_COLNAME => array(CreditNoteStatusFlowTableMap::ID => 0, CreditNoteStatusFlowTableMap::FROM_STATUS_ID => 1, CreditNoteStatusFlowTableMap::TO_STATUS_ID => 2, CreditNoteStatusFlowTableMap::PRIORITY => 3, CreditNoteStatusFlowTableMap::ROOT => 4, CreditNoteStatusFlowTableMap::CREATED_AT => 5, CreditNoteStatusFlowTableMap::UPDATED_AT => 6, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'FROM_STATUS_ID' => 1, 'TO_STATUS_ID' => 2, 'PRIORITY' => 3, 'ROOT' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
self::TYPE_FIELDNAME => array('id' => 0, 'from_status_id' => 1, 'to_status_id' => 2, 'priority' => 3, 'root' => 4, 'created_at' => 5, 'updated_at' => 6, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note_status_flow');
$this->setPhpName('CreditNoteStatusFlow');
$this->setClassName('\\CreditNote\\Model\\CreditNoteStatusFlow');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addForeignKey('FROM_STATUS_ID', 'FromStatusId', 'INTEGER', 'credit_note_status', 'ID', true, null, null);
$this->addForeignKey('TO_STATUS_ID', 'ToStatusId', 'INTEGER', 'credit_note_status', 'ID', true, null, null);
$this->addColumn('PRIORITY', 'Priority', 'INTEGER', false, 11, null);
$this->addColumn('ROOT', 'Root', 'BOOLEAN', true, 1, false);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CreditNoteStatusRelatedByFromStatusId', '\\CreditNote\\Model\\CreditNoteStatus', RelationMap::MANY_TO_ONE, array('from_status_id' => 'id', ), 'CASCADE', 'RESTRICT');
$this->addRelation('CreditNoteStatusRelatedByToStatusId', '\\CreditNote\\Model\\CreditNoteStatus', RelationMap::MANY_TO_ONE, array('to_status_id' => 'id', ), 'CASCADE', 'RESTRICT');
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteStatusFlowTableMap::CLASS_DEFAULT : CreditNoteStatusFlowTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNoteStatusFlow object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteStatusFlowTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteStatusFlowTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteStatusFlowTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteStatusFlowTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteStatusFlowTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteStatusFlowTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteStatusFlowTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteStatusFlowTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteStatusFlowTableMap::ID);
$criteria->addSelectColumn(CreditNoteStatusFlowTableMap::FROM_STATUS_ID);
$criteria->addSelectColumn(CreditNoteStatusFlowTableMap::TO_STATUS_ID);
$criteria->addSelectColumn(CreditNoteStatusFlowTableMap::PRIORITY);
$criteria->addSelectColumn(CreditNoteStatusFlowTableMap::ROOT);
$criteria->addSelectColumn(CreditNoteStatusFlowTableMap::CREATED_AT);
$criteria->addSelectColumn(CreditNoteStatusFlowTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.FROM_STATUS_ID');
$criteria->addSelectColumn($alias . '.TO_STATUS_ID');
$criteria->addSelectColumn($alias . '.PRIORITY');
$criteria->addSelectColumn($alias . '.ROOT');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusFlowTableMap::DATABASE_NAME)->getTable(CreditNoteStatusFlowTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusFlowTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteStatusFlowTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteStatusFlowTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNoteStatusFlow or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNoteStatusFlow object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNoteStatusFlow) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteStatusFlowTableMap::DATABASE_NAME);
$criteria->add(CreditNoteStatusFlowTableMap::ID, (array) $values, Criteria::IN);
}
$query = CreditNoteStatusFlowQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteStatusFlowTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteStatusFlowTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note_status_flow table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteStatusFlowQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNoteStatusFlow or Criteria object.
*
* @param mixed $criteria Criteria or CreditNoteStatusFlow object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusFlowTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteStatusFlow object
}
if ($criteria->containsKey(CreditNoteStatusFlowTableMap::ID) && $criteria->keyContainsValue(CreditNoteStatusFlowTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteStatusFlowTableMap::ID.')');
}
// Set the correct dbName
$query = CreditNoteStatusFlowQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteStatusFlowTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteStatusFlowTableMap::buildTableMap();

View File

@@ -0,0 +1,498 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNoteStatusI18n;
use CreditNote\Model\CreditNoteStatusI18nQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note_status_i18n' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteStatusI18nTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteStatusI18nTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note_status_i18n';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNoteStatusI18n';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNoteStatusI18n';
/**
* The total number of columns
*/
const NUM_COLUMNS = 6;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 6;
/**
* the column name for the ID field
*/
const ID = 'credit_note_status_i18n.ID';
/**
* the column name for the LOCALE field
*/
const LOCALE = 'credit_note_status_i18n.LOCALE';
/**
* the column name for the TITLE field
*/
const TITLE = 'credit_note_status_i18n.TITLE';
/**
* the column name for the DESCRIPTION field
*/
const DESCRIPTION = 'credit_note_status_i18n.DESCRIPTION';
/**
* the column name for the CHAPO field
*/
const CHAPO = 'credit_note_status_i18n.CHAPO';
/**
* the column name for the POSTSCRIPTUM field
*/
const POSTSCRIPTUM = 'credit_note_status_i18n.POSTSCRIPTUM';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
self::TYPE_COLNAME => array(CreditNoteStatusI18nTableMap::ID, CreditNoteStatusI18nTableMap::LOCALE, CreditNoteStatusI18nTableMap::TITLE, CreditNoteStatusI18nTableMap::DESCRIPTION, CreditNoteStatusI18nTableMap::CHAPO, CreditNoteStatusI18nTableMap::POSTSCRIPTUM, ),
self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
self::TYPE_COLNAME => array(CreditNoteStatusI18nTableMap::ID => 0, CreditNoteStatusI18nTableMap::LOCALE => 1, CreditNoteStatusI18nTableMap::TITLE => 2, CreditNoteStatusI18nTableMap::DESCRIPTION => 3, CreditNoteStatusI18nTableMap::CHAPO => 4, CreditNoteStatusI18nTableMap::POSTSCRIPTUM => 5, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note_status_i18n');
$this->setPhpName('CreditNoteStatusI18n');
$this->setClassName('\\CreditNote\\Model\\CreditNoteStatusI18n');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'credit_note_status', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
$this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CreditNoteStatus', '\\CreditNote\\Model\\CreditNoteStatus', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
} // buildRelations()
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by find*()
* and findPk*() calls.
*
* @param \CreditNote\Model\CreditNoteStatusI18n $obj A \CreditNote\Model\CreditNoteStatusI18n object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool($obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if (null === $key) {
$key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
} // if key === null
self::$instances[$key] = $obj;
}
}
/**
* Removes an object from the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doDelete
* methods in your stub classes -- you may need to explicitly remove objects
* from the cache in order to prevent returning objects that no longer exist.
*
* @param mixed $value A \CreditNote\Model\CreditNoteStatusI18n object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && null !== $value) {
if (is_object($value) && $value instanceof \CreditNote\Model\CreditNoteStatusI18n) {
$key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
} elseif (is_array($value) && count($value) === 2) {
// assume we've been passed a primary key";
$key = serialize(array((string) $value[0], (string) $value[1]));
} elseif ($value instanceof Criteria) {
self::$instances = [];
return;
} else {
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\CreditNoteStatusI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
throw $e;
}
unset(self::$instances[$key]);
}
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return $pks;
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteStatusI18nTableMap::CLASS_DEFAULT : CreditNoteStatusI18nTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNoteStatusI18n object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteStatusI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteStatusI18nTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteStatusI18nTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteStatusI18nTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteStatusI18nTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteStatusI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteStatusI18nTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteStatusI18nTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteStatusI18nTableMap::ID);
$criteria->addSelectColumn(CreditNoteStatusI18nTableMap::LOCALE);
$criteria->addSelectColumn(CreditNoteStatusI18nTableMap::TITLE);
$criteria->addSelectColumn(CreditNoteStatusI18nTableMap::DESCRIPTION);
$criteria->addSelectColumn(CreditNoteStatusI18nTableMap::CHAPO);
$criteria->addSelectColumn(CreditNoteStatusI18nTableMap::POSTSCRIPTUM);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.LOCALE');
$criteria->addSelectColumn($alias . '.TITLE');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.CHAPO');
$criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusI18nTableMap::DATABASE_NAME)->getTable(CreditNoteStatusI18nTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusI18nTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteStatusI18nTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteStatusI18nTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNoteStatusI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNoteStatusI18n object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNoteStatusI18n) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteStatusI18nTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(CreditNoteStatusI18nTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(CreditNoteStatusI18nTableMap::LOCALE, $value[1]));
$criteria->addOr($criterion);
}
}
$query = CreditNoteStatusI18nQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteStatusI18nTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteStatusI18nTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note_status_i18n table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteStatusI18nQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNoteStatusI18n or Criteria object.
*
* @param mixed $criteria Criteria or CreditNoteStatusI18n object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusI18nTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteStatusI18n object
}
// Set the correct dbName
$query = CreditNoteStatusI18nQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteStatusI18nTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteStatusI18nTableMap::buildTableMap();

View File

@@ -0,0 +1,495 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNoteStatus;
use CreditNote\Model\CreditNoteStatusQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note_status' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteStatusTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteStatusTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note_status';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNoteStatus';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNoteStatus';
/**
* The total number of columns
*/
const NUM_COLUMNS = 8;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 8;
/**
* the column name for the ID field
*/
const ID = 'credit_note_status.ID';
/**
* the column name for the CODE field
*/
const CODE = 'credit_note_status.CODE';
/**
* the column name for the COLOR field
*/
const COLOR = 'credit_note_status.COLOR';
/**
* the column name for the INVOICED field
*/
const INVOICED = 'credit_note_status.INVOICED';
/**
* the column name for the USED field
*/
const USED = 'credit_note_status.USED';
/**
* the column name for the POSITION field
*/
const POSITION = 'credit_note_status.POSITION';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'credit_note_status.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'credit_note_status.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
// i18n behavior
/**
* The default locale to use for translations.
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Code', 'Color', 'Invoiced', 'Used', 'Position', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'code', 'color', 'invoiced', 'used', 'position', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CreditNoteStatusTableMap::ID, CreditNoteStatusTableMap::CODE, CreditNoteStatusTableMap::COLOR, CreditNoteStatusTableMap::INVOICED, CreditNoteStatusTableMap::USED, CreditNoteStatusTableMap::POSITION, CreditNoteStatusTableMap::CREATED_AT, CreditNoteStatusTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'COLOR', 'INVOICED', 'USED', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'code', 'color', 'invoiced', 'used', 'position', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Color' => 2, 'Invoiced' => 3, 'Used' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'color' => 2, 'invoiced' => 3, 'used' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
self::TYPE_COLNAME => array(CreditNoteStatusTableMap::ID => 0, CreditNoteStatusTableMap::CODE => 1, CreditNoteStatusTableMap::COLOR => 2, CreditNoteStatusTableMap::INVOICED => 3, CreditNoteStatusTableMap::USED => 4, CreditNoteStatusTableMap::POSITION => 5, CreditNoteStatusTableMap::CREATED_AT => 6, CreditNoteStatusTableMap::UPDATED_AT => 7, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'COLOR' => 2, 'INVOICED' => 3, 'USED' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'color' => 2, 'invoiced' => 3, 'used' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note_status');
$this->setPhpName('CreditNoteStatus');
$this->setClassName('\\CreditNote\\Model\\CreditNoteStatus');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
$this->addColumn('COLOR', 'Color', 'CHAR', false, 7, null);
$this->addColumn('INVOICED', 'Invoiced', 'BOOLEAN', true, 1, false);
$this->addColumn('USED', 'Used', 'BOOLEAN', true, 1, false);
$this->addColumn('POSITION', 'Position', 'INTEGER', false, 11, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'RESTRICT', 'RESTRICT', 'CreditNotes');
$this->addRelation('CreditNoteStatusFlowRelatedByFromStatusId', '\\CreditNote\\Model\\CreditNoteStatusFlow', RelationMap::ONE_TO_MANY, array('id' => 'from_status_id', ), 'CASCADE', 'RESTRICT', 'CreditNoteStatusFlowsRelatedByFromStatusId');
$this->addRelation('CreditNoteStatusFlowRelatedByToStatusId', '\\CreditNote\\Model\\CreditNoteStatusFlow', RelationMap::ONE_TO_MANY, array('id' => 'to_status_id', ), 'CASCADE', 'RESTRICT', 'CreditNoteStatusFlowsRelatedByToStatusId');
$this->addRelation('CreditNoteStatusI18n', '\\CreditNote\\Model\\CreditNoteStatusI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CreditNoteStatusI18ns');
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Method to invalidate the instance pool of all tables related to credit_note_status * by a foreign key with ON DELETE CASCADE
*/
public static function clearRelatedInstancePool()
{
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CreditNoteStatusFlowTableMap::clearInstancePool();
CreditNoteStatusI18nTableMap::clearInstancePool();
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteStatusTableMap::CLASS_DEFAULT : CreditNoteStatusTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNoteStatus object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteStatusTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteStatusTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteStatusTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteStatusTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteStatusTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteStatusTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteStatusTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteStatusTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteStatusTableMap::ID);
$criteria->addSelectColumn(CreditNoteStatusTableMap::CODE);
$criteria->addSelectColumn(CreditNoteStatusTableMap::COLOR);
$criteria->addSelectColumn(CreditNoteStatusTableMap::INVOICED);
$criteria->addSelectColumn(CreditNoteStatusTableMap::USED);
$criteria->addSelectColumn(CreditNoteStatusTableMap::POSITION);
$criteria->addSelectColumn(CreditNoteStatusTableMap::CREATED_AT);
$criteria->addSelectColumn(CreditNoteStatusTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.CODE');
$criteria->addSelectColumn($alias . '.COLOR');
$criteria->addSelectColumn($alias . '.INVOICED');
$criteria->addSelectColumn($alias . '.USED');
$criteria->addSelectColumn($alias . '.POSITION');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusTableMap::DATABASE_NAME)->getTable(CreditNoteStatusTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteStatusTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteStatusTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteStatusTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNoteStatus or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNoteStatus object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNoteStatus) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteStatusTableMap::DATABASE_NAME);
$criteria->add(CreditNoteStatusTableMap::ID, (array) $values, Criteria::IN);
}
$query = CreditNoteStatusQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteStatusTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteStatusTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note_status table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteStatusQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNoteStatus or Criteria object.
*
* @param mixed $criteria Criteria or CreditNoteStatus object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteStatusTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteStatus object
}
if ($criteria->containsKey(CreditNoteStatusTableMap::ID) && $criteria->keyContainsValue(CreditNoteStatusTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteStatusTableMap::ID.')');
}
// Set the correct dbName
$query = CreditNoteStatusQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteStatusTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteStatusTableMap::buildTableMap();

View File

@@ -0,0 +1,610 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNote;
use CreditNote\Model\CreditNoteQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNote';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNote';
/**
* The total number of columns
*/
const NUM_COLUMNS = 22;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 22;
/**
* the column name for the ID field
*/
const ID = 'credit_note.ID';
/**
* the column name for the REF field
*/
const REF = 'credit_note.REF';
/**
* the column name for the INVOICE_REF field
*/
const INVOICE_REF = 'credit_note.INVOICE_REF';
/**
* the column name for the INVOICE_ADDRESS_ID field
*/
const INVOICE_ADDRESS_ID = 'credit_note.INVOICE_ADDRESS_ID';
/**
* the column name for the INVOICE_DATE field
*/
const INVOICE_DATE = 'credit_note.INVOICE_DATE';
/**
* the column name for the ORDER_ID field
*/
const ORDER_ID = 'credit_note.ORDER_ID';
/**
* the column name for the CUSTOMER_ID field
*/
const CUSTOMER_ID = 'credit_note.CUSTOMER_ID';
/**
* the column name for the PARENT_ID field
*/
const PARENT_ID = 'credit_note.PARENT_ID';
/**
* the column name for the TYPE_ID field
*/
const TYPE_ID = 'credit_note.TYPE_ID';
/**
* the column name for the STATUS_ID field
*/
const STATUS_ID = 'credit_note.STATUS_ID';
/**
* the column name for the CURRENCY_ID field
*/
const CURRENCY_ID = 'credit_note.CURRENCY_ID';
/**
* the column name for the CURRENCY_RATE field
*/
const CURRENCY_RATE = 'credit_note.CURRENCY_RATE';
/**
* the column name for the TOTAL_PRICE field
*/
const TOTAL_PRICE = 'credit_note.TOTAL_PRICE';
/**
* the column name for the TOTAL_PRICE_WITH_TAX field
*/
const TOTAL_PRICE_WITH_TAX = 'credit_note.TOTAL_PRICE_WITH_TAX';
/**
* the column name for the DISCOUNT_WITHOUT_TAX field
*/
const DISCOUNT_WITHOUT_TAX = 'credit_note.DISCOUNT_WITHOUT_TAX';
/**
* the column name for the DISCOUNT_WITH_TAX field
*/
const DISCOUNT_WITH_TAX = 'credit_note.DISCOUNT_WITH_TAX';
/**
* the column name for the ALLOW_PARTIAL_USE field
*/
const ALLOW_PARTIAL_USE = 'credit_note.ALLOW_PARTIAL_USE';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'credit_note.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'credit_note.UPDATED_AT';
/**
* the column name for the VERSION field
*/
const VERSION = 'credit_note.VERSION';
/**
* the column name for the VERSION_CREATED_AT field
*/
const VERSION_CREATED_AT = 'credit_note.VERSION_CREATED_AT';
/**
* the column name for the VERSION_CREATED_BY field
*/
const VERSION_CREATED_BY = 'credit_note.VERSION_CREATED_BY';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Ref', 'InvoiceRef', 'InvoiceAddressId', 'InvoiceDate', 'OrderId', 'CustomerId', 'ParentId', 'TypeId', 'StatusId', 'CurrencyId', 'CurrencyRate', 'TotalPrice', 'TotalPriceWithTax', 'DiscountWithoutTax', 'DiscountWithTax', 'AllowPartialUse', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'invoiceRef', 'invoiceAddressId', 'invoiceDate', 'orderId', 'customerId', 'parentId', 'typeId', 'statusId', 'currencyId', 'currencyRate', 'totalPrice', 'totalPriceWithTax', 'discountWithoutTax', 'discountWithTax', 'allowPartialUse', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
self::TYPE_COLNAME => array(CreditNoteTableMap::ID, CreditNoteTableMap::REF, CreditNoteTableMap::INVOICE_REF, CreditNoteTableMap::INVOICE_ADDRESS_ID, CreditNoteTableMap::INVOICE_DATE, CreditNoteTableMap::ORDER_ID, CreditNoteTableMap::CUSTOMER_ID, CreditNoteTableMap::PARENT_ID, CreditNoteTableMap::TYPE_ID, CreditNoteTableMap::STATUS_ID, CreditNoteTableMap::CURRENCY_ID, CreditNoteTableMap::CURRENCY_RATE, CreditNoteTableMap::TOTAL_PRICE, CreditNoteTableMap::TOTAL_PRICE_WITH_TAX, CreditNoteTableMap::DISCOUNT_WITHOUT_TAX, CreditNoteTableMap::DISCOUNT_WITH_TAX, CreditNoteTableMap::ALLOW_PARTIAL_USE, CreditNoteTableMap::CREATED_AT, CreditNoteTableMap::UPDATED_AT, CreditNoteTableMap::VERSION, CreditNoteTableMap::VERSION_CREATED_AT, CreditNoteTableMap::VERSION_CREATED_BY, ),
self::TYPE_RAW_COLNAME => array('ID', 'REF', 'INVOICE_REF', 'INVOICE_ADDRESS_ID', 'INVOICE_DATE', 'ORDER_ID', 'CUSTOMER_ID', 'PARENT_ID', 'TYPE_ID', 'STATUS_ID', 'CURRENCY_ID', 'CURRENCY_RATE', 'TOTAL_PRICE', 'TOTAL_PRICE_WITH_TAX', 'DISCOUNT_WITHOUT_TAX', 'DISCOUNT_WITH_TAX', 'ALLOW_PARTIAL_USE', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
self::TYPE_FIELDNAME => array('id', 'ref', 'invoice_ref', 'invoice_address_id', 'invoice_date', 'order_id', 'customer_id', 'parent_id', 'type_id', 'status_id', 'currency_id', 'currency_rate', 'total_price', 'total_price_with_tax', 'discount_without_tax', 'discount_with_tax', 'allow_partial_use', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'InvoiceRef' => 2, 'InvoiceAddressId' => 3, 'InvoiceDate' => 4, 'OrderId' => 5, 'CustomerId' => 6, 'ParentId' => 7, 'TypeId' => 8, 'StatusId' => 9, 'CurrencyId' => 10, 'CurrencyRate' => 11, 'TotalPrice' => 12, 'TotalPriceWithTax' => 13, 'DiscountWithoutTax' => 14, 'DiscountWithTax' => 15, 'AllowPartialUse' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, 'Version' => 19, 'VersionCreatedAt' => 20, 'VersionCreatedBy' => 21, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'invoiceRef' => 2, 'invoiceAddressId' => 3, 'invoiceDate' => 4, 'orderId' => 5, 'customerId' => 6, 'parentId' => 7, 'typeId' => 8, 'statusId' => 9, 'currencyId' => 10, 'currencyRate' => 11, 'totalPrice' => 12, 'totalPriceWithTax' => 13, 'discountWithoutTax' => 14, 'discountWithTax' => 15, 'allowPartialUse' => 16, 'createdAt' => 17, 'updatedAt' => 18, 'version' => 19, 'versionCreatedAt' => 20, 'versionCreatedBy' => 21, ),
self::TYPE_COLNAME => array(CreditNoteTableMap::ID => 0, CreditNoteTableMap::REF => 1, CreditNoteTableMap::INVOICE_REF => 2, CreditNoteTableMap::INVOICE_ADDRESS_ID => 3, CreditNoteTableMap::INVOICE_DATE => 4, CreditNoteTableMap::ORDER_ID => 5, CreditNoteTableMap::CUSTOMER_ID => 6, CreditNoteTableMap::PARENT_ID => 7, CreditNoteTableMap::TYPE_ID => 8, CreditNoteTableMap::STATUS_ID => 9, CreditNoteTableMap::CURRENCY_ID => 10, CreditNoteTableMap::CURRENCY_RATE => 11, CreditNoteTableMap::TOTAL_PRICE => 12, CreditNoteTableMap::TOTAL_PRICE_WITH_TAX => 13, CreditNoteTableMap::DISCOUNT_WITHOUT_TAX => 14, CreditNoteTableMap::DISCOUNT_WITH_TAX => 15, CreditNoteTableMap::ALLOW_PARTIAL_USE => 16, CreditNoteTableMap::CREATED_AT => 17, CreditNoteTableMap::UPDATED_AT => 18, CreditNoteTableMap::VERSION => 19, CreditNoteTableMap::VERSION_CREATED_AT => 20, CreditNoteTableMap::VERSION_CREATED_BY => 21, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'INVOICE_REF' => 2, 'INVOICE_ADDRESS_ID' => 3, 'INVOICE_DATE' => 4, 'ORDER_ID' => 5, 'CUSTOMER_ID' => 6, 'PARENT_ID' => 7, 'TYPE_ID' => 8, 'STATUS_ID' => 9, 'CURRENCY_ID' => 10, 'CURRENCY_RATE' => 11, 'TOTAL_PRICE' => 12, 'TOTAL_PRICE_WITH_TAX' => 13, 'DISCOUNT_WITHOUT_TAX' => 14, 'DISCOUNT_WITH_TAX' => 15, 'ALLOW_PARTIAL_USE' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, 'VERSION' => 19, 'VERSION_CREATED_AT' => 20, 'VERSION_CREATED_BY' => 21, ),
self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'invoice_ref' => 2, 'invoice_address_id' => 3, 'invoice_date' => 4, 'order_id' => 5, 'customer_id' => 6, 'parent_id' => 7, 'type_id' => 8, 'status_id' => 9, 'currency_id' => 10, 'currency_rate' => 11, 'total_price' => 12, 'total_price_with_tax' => 13, 'discount_without_tax' => 14, 'discount_with_tax' => 15, 'allow_partial_use' => 16, 'created_at' => 17, 'updated_at' => 18, 'version' => 19, 'version_created_at' => 20, 'version_created_by' => 21, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note');
$this->setPhpName('CreditNote');
$this->setClassName('\\CreditNote\\Model\\CreditNote');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null);
$this->addColumn('INVOICE_REF', 'InvoiceRef', 'VARCHAR', false, 45, null);
$this->addForeignKey('INVOICE_ADDRESS_ID', 'InvoiceAddressId', 'INTEGER', 'credit_note_address', 'ID', true, null, null);
$this->addColumn('INVOICE_DATE', 'InvoiceDate', 'TIMESTAMP', false, null, null);
$this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', false, null, null);
$this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
$this->addForeignKey('PARENT_ID', 'ParentId', 'INTEGER', 'credit_note', 'ID', false, null, null);
$this->addForeignKey('TYPE_ID', 'TypeId', 'INTEGER', 'credit_note_type', 'ID', true, null, null);
$this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'credit_note_status', 'ID', true, null, null);
$this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', true, null, null);
$this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', false, null, null);
$this->addColumn('TOTAL_PRICE', 'TotalPrice', 'DECIMAL', false, 16, 0);
$this->addColumn('TOTAL_PRICE_WITH_TAX', 'TotalPriceWithTax', 'DECIMAL', false, 16, 0);
$this->addColumn('DISCOUNT_WITHOUT_TAX', 'DiscountWithoutTax', 'DECIMAL', false, 16, 0);
$this->addColumn('DISCOUNT_WITH_TAX', 'DiscountWithTax', 'DECIMAL', false, 16, 0);
$this->addColumn('ALLOW_PARTIAL_USE', 'AllowPartialUse', 'BOOLEAN', false, 1, true);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
$this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('CreditNoteRelatedByParentId', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('parent_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('CreditNoteType', '\\CreditNote\\Model\\CreditNoteType', RelationMap::MANY_TO_ONE, array('type_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('CreditNoteStatus', '\\CreditNote\\Model\\CreditNoteStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('CreditNoteAddress', '\\CreditNote\\Model\\CreditNoteAddress', RelationMap::MANY_TO_ONE, array('invoice_address_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('CreditNoteRelatedById', '\\CreditNote\\Model\\CreditNote', RelationMap::ONE_TO_MANY, array('id' => 'parent_id', ), 'RESTRICT', 'RESTRICT', 'CreditNotesRelatedById');
$this->addRelation('OrderCreditNote', '\\CreditNote\\Model\\OrderCreditNote', RelationMap::ONE_TO_MANY, array('id' => 'credit_note_id', ), 'CASCADE', 'RESTRICT', 'OrderCreditNotes');
$this->addRelation('CartCreditNote', '\\CreditNote\\Model\\CartCreditNote', RelationMap::ONE_TO_MANY, array('id' => 'credit_note_id', ), 'CASCADE', 'RESTRICT', 'CartCreditNotes');
$this->addRelation('CreditNoteDetail', '\\CreditNote\\Model\\CreditNoteDetail', RelationMap::ONE_TO_MANY, array('id' => 'credit_note_id', ), 'CASCADE', 'RESTRICT', 'CreditNoteDetails');
$this->addRelation('CreditNoteComment', '\\CreditNote\\Model\\CreditNoteComment', RelationMap::ONE_TO_MANY, array('id' => 'credit_note_id', ), 'CASCADE', 'RESTRICT', 'CreditNoteComments');
$this->addRelation('CreditNoteVersion', '\\CreditNote\\Model\\CreditNoteVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CreditNoteVersions');
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
);
} // getBehaviors()
/**
* Method to invalidate the instance pool of all tables related to credit_note * by a foreign key with ON DELETE CASCADE
*/
public static function clearRelatedInstancePool()
{
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
OrderCreditNoteTableMap::clearInstancePool();
CartCreditNoteTableMap::clearInstancePool();
CreditNoteDetailTableMap::clearInstancePool();
CreditNoteCommentTableMap::clearInstancePool();
CreditNoteVersionTableMap::clearInstancePool();
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteTableMap::CLASS_DEFAULT : CreditNoteTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNote object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteTableMap::ID);
$criteria->addSelectColumn(CreditNoteTableMap::REF);
$criteria->addSelectColumn(CreditNoteTableMap::INVOICE_REF);
$criteria->addSelectColumn(CreditNoteTableMap::INVOICE_ADDRESS_ID);
$criteria->addSelectColumn(CreditNoteTableMap::INVOICE_DATE);
$criteria->addSelectColumn(CreditNoteTableMap::ORDER_ID);
$criteria->addSelectColumn(CreditNoteTableMap::CUSTOMER_ID);
$criteria->addSelectColumn(CreditNoteTableMap::PARENT_ID);
$criteria->addSelectColumn(CreditNoteTableMap::TYPE_ID);
$criteria->addSelectColumn(CreditNoteTableMap::STATUS_ID);
$criteria->addSelectColumn(CreditNoteTableMap::CURRENCY_ID);
$criteria->addSelectColumn(CreditNoteTableMap::CURRENCY_RATE);
$criteria->addSelectColumn(CreditNoteTableMap::TOTAL_PRICE);
$criteria->addSelectColumn(CreditNoteTableMap::TOTAL_PRICE_WITH_TAX);
$criteria->addSelectColumn(CreditNoteTableMap::DISCOUNT_WITHOUT_TAX);
$criteria->addSelectColumn(CreditNoteTableMap::DISCOUNT_WITH_TAX);
$criteria->addSelectColumn(CreditNoteTableMap::ALLOW_PARTIAL_USE);
$criteria->addSelectColumn(CreditNoteTableMap::CREATED_AT);
$criteria->addSelectColumn(CreditNoteTableMap::UPDATED_AT);
$criteria->addSelectColumn(CreditNoteTableMap::VERSION);
$criteria->addSelectColumn(CreditNoteTableMap::VERSION_CREATED_AT);
$criteria->addSelectColumn(CreditNoteTableMap::VERSION_CREATED_BY);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.REF');
$criteria->addSelectColumn($alias . '.INVOICE_REF');
$criteria->addSelectColumn($alias . '.INVOICE_ADDRESS_ID');
$criteria->addSelectColumn($alias . '.INVOICE_DATE');
$criteria->addSelectColumn($alias . '.ORDER_ID');
$criteria->addSelectColumn($alias . '.CUSTOMER_ID');
$criteria->addSelectColumn($alias . '.PARENT_ID');
$criteria->addSelectColumn($alias . '.TYPE_ID');
$criteria->addSelectColumn($alias . '.STATUS_ID');
$criteria->addSelectColumn($alias . '.CURRENCY_ID');
$criteria->addSelectColumn($alias . '.CURRENCY_RATE');
$criteria->addSelectColumn($alias . '.TOTAL_PRICE');
$criteria->addSelectColumn($alias . '.TOTAL_PRICE_WITH_TAX');
$criteria->addSelectColumn($alias . '.DISCOUNT_WITHOUT_TAX');
$criteria->addSelectColumn($alias . '.DISCOUNT_WITH_TAX');
$criteria->addSelectColumn($alias . '.ALLOW_PARTIAL_USE');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
$criteria->addSelectColumn($alias . '.VERSION');
$criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
$criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteTableMap::DATABASE_NAME)->getTable(CreditNoteTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNote or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNote object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNote) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteTableMap::DATABASE_NAME);
$criteria->add(CreditNoteTableMap::ID, (array) $values, Criteria::IN);
}
$query = CreditNoteQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNote or Criteria object.
*
* @param mixed $criteria Criteria or CreditNote object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNote object
}
if ($criteria->containsKey(CreditNoteTableMap::ID) && $criteria->keyContainsValue(CreditNoteTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteTableMap::ID.')');
}
// Set the correct dbName
$query = CreditNoteQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteTableMap::buildTableMap();

View File

@@ -0,0 +1,498 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNoteTypeI18n;
use CreditNote\Model\CreditNoteTypeI18nQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note_type_i18n' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteTypeI18nTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteTypeI18nTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note_type_i18n';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNoteTypeI18n';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNoteTypeI18n';
/**
* The total number of columns
*/
const NUM_COLUMNS = 6;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 6;
/**
* the column name for the ID field
*/
const ID = 'credit_note_type_i18n.ID';
/**
* the column name for the LOCALE field
*/
const LOCALE = 'credit_note_type_i18n.LOCALE';
/**
* the column name for the TITLE field
*/
const TITLE = 'credit_note_type_i18n.TITLE';
/**
* the column name for the DESCRIPTION field
*/
const DESCRIPTION = 'credit_note_type_i18n.DESCRIPTION';
/**
* the column name for the CHAPO field
*/
const CHAPO = 'credit_note_type_i18n.CHAPO';
/**
* the column name for the POSTSCRIPTUM field
*/
const POSTSCRIPTUM = 'credit_note_type_i18n.POSTSCRIPTUM';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
self::TYPE_COLNAME => array(CreditNoteTypeI18nTableMap::ID, CreditNoteTypeI18nTableMap::LOCALE, CreditNoteTypeI18nTableMap::TITLE, CreditNoteTypeI18nTableMap::DESCRIPTION, CreditNoteTypeI18nTableMap::CHAPO, CreditNoteTypeI18nTableMap::POSTSCRIPTUM, ),
self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
self::TYPE_COLNAME => array(CreditNoteTypeI18nTableMap::ID => 0, CreditNoteTypeI18nTableMap::LOCALE => 1, CreditNoteTypeI18nTableMap::TITLE => 2, CreditNoteTypeI18nTableMap::DESCRIPTION => 3, CreditNoteTypeI18nTableMap::CHAPO => 4, CreditNoteTypeI18nTableMap::POSTSCRIPTUM => 5, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note_type_i18n');
$this->setPhpName('CreditNoteTypeI18n');
$this->setClassName('\\CreditNote\\Model\\CreditNoteTypeI18n');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'credit_note_type', 'ID', true, null, null);
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
$this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CreditNoteType', '\\CreditNote\\Model\\CreditNoteType', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
} // buildRelations()
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by find*()
* and findPk*() calls.
*
* @param \CreditNote\Model\CreditNoteTypeI18n $obj A \CreditNote\Model\CreditNoteTypeI18n object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool($obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if (null === $key) {
$key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
} // if key === null
self::$instances[$key] = $obj;
}
}
/**
* Removes an object from the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doDelete
* methods in your stub classes -- you may need to explicitly remove objects
* from the cache in order to prevent returning objects that no longer exist.
*
* @param mixed $value A \CreditNote\Model\CreditNoteTypeI18n object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && null !== $value) {
if (is_object($value) && $value instanceof \CreditNote\Model\CreditNoteTypeI18n) {
$key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
} elseif (is_array($value) && count($value) === 2) {
// assume we've been passed a primary key";
$key = serialize(array((string) $value[0], (string) $value[1]));
} elseif ($value instanceof Criteria) {
self::$instances = [];
return;
} else {
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\CreditNoteTypeI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
throw $e;
}
unset(self::$instances[$key]);
}
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return $pks;
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteTypeI18nTableMap::CLASS_DEFAULT : CreditNoteTypeI18nTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNoteTypeI18n object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteTypeI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteTypeI18nTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteTypeI18nTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteTypeI18nTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteTypeI18nTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteTypeI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteTypeI18nTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteTypeI18nTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteTypeI18nTableMap::ID);
$criteria->addSelectColumn(CreditNoteTypeI18nTableMap::LOCALE);
$criteria->addSelectColumn(CreditNoteTypeI18nTableMap::TITLE);
$criteria->addSelectColumn(CreditNoteTypeI18nTableMap::DESCRIPTION);
$criteria->addSelectColumn(CreditNoteTypeI18nTableMap::CHAPO);
$criteria->addSelectColumn(CreditNoteTypeI18nTableMap::POSTSCRIPTUM);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.LOCALE');
$criteria->addSelectColumn($alias . '.TITLE');
$criteria->addSelectColumn($alias . '.DESCRIPTION');
$criteria->addSelectColumn($alias . '.CHAPO');
$criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteTypeI18nTableMap::DATABASE_NAME)->getTable(CreditNoteTypeI18nTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteTypeI18nTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteTypeI18nTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteTypeI18nTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNoteTypeI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNoteTypeI18n object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNoteTypeI18n) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteTypeI18nTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(CreditNoteTypeI18nTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(CreditNoteTypeI18nTableMap::LOCALE, $value[1]));
$criteria->addOr($criterion);
}
}
$query = CreditNoteTypeI18nQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteTypeI18nTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteTypeI18nTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note_type_i18n table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteTypeI18nQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNoteTypeI18n or Criteria object.
*
* @param mixed $criteria Criteria or CreditNoteTypeI18n object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeI18nTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteTypeI18n object
}
// Set the correct dbName
$query = CreditNoteTypeI18nQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteTypeI18nTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteTypeI18nTableMap::buildTableMap();

View File

@@ -0,0 +1,484 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNoteType;
use CreditNote\Model\CreditNoteTypeQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note_type' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteTypeTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteTypeTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note_type';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNoteType';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNoteType';
/**
* The total number of columns
*/
const NUM_COLUMNS = 7;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 7;
/**
* the column name for the ID field
*/
const ID = 'credit_note_type.ID';
/**
* the column name for the CODE field
*/
const CODE = 'credit_note_type.CODE';
/**
* the column name for the COLOR field
*/
const COLOR = 'credit_note_type.COLOR';
/**
* the column name for the POSITION field
*/
const POSITION = 'credit_note_type.POSITION';
/**
* the column name for the REQUIRED_ORDER field
*/
const REQUIRED_ORDER = 'credit_note_type.REQUIRED_ORDER';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'credit_note_type.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'credit_note_type.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
// i18n behavior
/**
* The default locale to use for translations.
*
* @var string
*/
const DEFAULT_LOCALE = 'en_US';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Code', 'Color', 'Position', 'RequiredOrder', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'code', 'color', 'position', 'requiredOrder', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CreditNoteTypeTableMap::ID, CreditNoteTypeTableMap::CODE, CreditNoteTypeTableMap::COLOR, CreditNoteTypeTableMap::POSITION, CreditNoteTypeTableMap::REQUIRED_ORDER, CreditNoteTypeTableMap::CREATED_AT, CreditNoteTypeTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'COLOR', 'POSITION', 'REQUIRED_ORDER', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'code', 'color', 'position', 'required_order', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Color' => 2, 'Position' => 3, 'RequiredOrder' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'color' => 2, 'position' => 3, 'requiredOrder' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
self::TYPE_COLNAME => array(CreditNoteTypeTableMap::ID => 0, CreditNoteTypeTableMap::CODE => 1, CreditNoteTypeTableMap::COLOR => 2, CreditNoteTypeTableMap::POSITION => 3, CreditNoteTypeTableMap::REQUIRED_ORDER => 4, CreditNoteTypeTableMap::CREATED_AT => 5, CreditNoteTypeTableMap::UPDATED_AT => 6, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'COLOR' => 2, 'POSITION' => 3, 'REQUIRED_ORDER' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'color' => 2, 'position' => 3, 'required_order' => 4, 'created_at' => 5, 'updated_at' => 6, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note_type');
$this->setPhpName('CreditNoteType');
$this->setClassName('\\CreditNote\\Model\\CreditNoteType');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
$this->addColumn('COLOR', 'Color', 'CHAR', false, 7, null);
$this->addColumn('POSITION', 'Position', 'INTEGER', false, 11, null);
$this->addColumn('REQUIRED_ORDER', 'RequiredOrder', 'BOOLEAN', true, 1, false);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::ONE_TO_MANY, array('id' => 'type_id', ), 'RESTRICT', 'RESTRICT', 'CreditNotes');
$this->addRelation('CreditNoteTypeI18n', '\\CreditNote\\Model\\CreditNoteTypeI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CreditNoteTypeI18ns');
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Method to invalidate the instance pool of all tables related to credit_note_type * by a foreign key with ON DELETE CASCADE
*/
public static function clearRelatedInstancePool()
{
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
CreditNoteTypeI18nTableMap::clearInstancePool();
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return (int) $row[
$indexType == TableMap::TYPE_NUM
? 0 + $offset
: self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
];
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteTypeTableMap::CLASS_DEFAULT : CreditNoteTypeTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNoteType object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteTypeTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteTypeTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteTypeTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteTypeTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteTypeTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteTypeTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteTypeTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteTypeTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteTypeTableMap::ID);
$criteria->addSelectColumn(CreditNoteTypeTableMap::CODE);
$criteria->addSelectColumn(CreditNoteTypeTableMap::COLOR);
$criteria->addSelectColumn(CreditNoteTypeTableMap::POSITION);
$criteria->addSelectColumn(CreditNoteTypeTableMap::REQUIRED_ORDER);
$criteria->addSelectColumn(CreditNoteTypeTableMap::CREATED_AT);
$criteria->addSelectColumn(CreditNoteTypeTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.CODE');
$criteria->addSelectColumn($alias . '.COLOR');
$criteria->addSelectColumn($alias . '.POSITION');
$criteria->addSelectColumn($alias . '.REQUIRED_ORDER');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteTypeTableMap::DATABASE_NAME)->getTable(CreditNoteTypeTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteTypeTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteTypeTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteTypeTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNoteType or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNoteType object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNoteType) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteTypeTableMap::DATABASE_NAME);
$criteria->add(CreditNoteTypeTableMap::ID, (array) $values, Criteria::IN);
}
$query = CreditNoteTypeQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteTypeTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteTypeTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note_type table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteTypeQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNoteType or Criteria object.
*
* @param mixed $criteria Criteria or CreditNoteType object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteTypeTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteType object
}
if ($criteria->containsKey(CreditNoteTypeTableMap::ID) && $criteria->keyContainsValue(CreditNoteTypeTableMap::ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CreditNoteTypeTableMap::ID.')');
}
// Set the correct dbName
$query = CreditNoteTypeQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteTypeTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteTypeTableMap::buildTableMap();

View File

@@ -0,0 +1,666 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\CreditNoteVersion;
use CreditNote\Model\CreditNoteVersionQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'credit_note_version' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class CreditNoteVersionTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.CreditNoteVersionTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'credit_note_version';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\CreditNoteVersion';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.CreditNoteVersion';
/**
* The total number of columns
*/
const NUM_COLUMNS = 27;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 27;
/**
* the column name for the ID field
*/
const ID = 'credit_note_version.ID';
/**
* the column name for the REF field
*/
const REF = 'credit_note_version.REF';
/**
* the column name for the INVOICE_REF field
*/
const INVOICE_REF = 'credit_note_version.INVOICE_REF';
/**
* the column name for the INVOICE_ADDRESS_ID field
*/
const INVOICE_ADDRESS_ID = 'credit_note_version.INVOICE_ADDRESS_ID';
/**
* the column name for the INVOICE_DATE field
*/
const INVOICE_DATE = 'credit_note_version.INVOICE_DATE';
/**
* the column name for the ORDER_ID field
*/
const ORDER_ID = 'credit_note_version.ORDER_ID';
/**
* the column name for the CUSTOMER_ID field
*/
const CUSTOMER_ID = 'credit_note_version.CUSTOMER_ID';
/**
* the column name for the PARENT_ID field
*/
const PARENT_ID = 'credit_note_version.PARENT_ID';
/**
* the column name for the TYPE_ID field
*/
const TYPE_ID = 'credit_note_version.TYPE_ID';
/**
* the column name for the STATUS_ID field
*/
const STATUS_ID = 'credit_note_version.STATUS_ID';
/**
* the column name for the CURRENCY_ID field
*/
const CURRENCY_ID = 'credit_note_version.CURRENCY_ID';
/**
* the column name for the CURRENCY_RATE field
*/
const CURRENCY_RATE = 'credit_note_version.CURRENCY_RATE';
/**
* the column name for the TOTAL_PRICE field
*/
const TOTAL_PRICE = 'credit_note_version.TOTAL_PRICE';
/**
* the column name for the TOTAL_PRICE_WITH_TAX field
*/
const TOTAL_PRICE_WITH_TAX = 'credit_note_version.TOTAL_PRICE_WITH_TAX';
/**
* the column name for the DISCOUNT_WITHOUT_TAX field
*/
const DISCOUNT_WITHOUT_TAX = 'credit_note_version.DISCOUNT_WITHOUT_TAX';
/**
* the column name for the DISCOUNT_WITH_TAX field
*/
const DISCOUNT_WITH_TAX = 'credit_note_version.DISCOUNT_WITH_TAX';
/**
* the column name for the ALLOW_PARTIAL_USE field
*/
const ALLOW_PARTIAL_USE = 'credit_note_version.ALLOW_PARTIAL_USE';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'credit_note_version.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'credit_note_version.UPDATED_AT';
/**
* the column name for the VERSION field
*/
const VERSION = 'credit_note_version.VERSION';
/**
* the column name for the VERSION_CREATED_AT field
*/
const VERSION_CREATED_AT = 'credit_note_version.VERSION_CREATED_AT';
/**
* the column name for the VERSION_CREATED_BY field
*/
const VERSION_CREATED_BY = 'credit_note_version.VERSION_CREATED_BY';
/**
* the column name for the ORDER_ID_VERSION field
*/
const ORDER_ID_VERSION = 'credit_note_version.ORDER_ID_VERSION';
/**
* the column name for the CUSTOMER_ID_VERSION field
*/
const CUSTOMER_ID_VERSION = 'credit_note_version.CUSTOMER_ID_VERSION';
/**
* the column name for the PARENT_ID_VERSION field
*/
const PARENT_ID_VERSION = 'credit_note_version.PARENT_ID_VERSION';
/**
* the column name for the CREDIT_NOTE_IDS field
*/
const CREDIT_NOTE_IDS = 'credit_note_version.CREDIT_NOTE_IDS';
/**
* the column name for the CREDIT_NOTE_VERSIONS field
*/
const CREDIT_NOTE_VERSIONS = 'credit_note_version.CREDIT_NOTE_VERSIONS';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Ref', 'InvoiceRef', 'InvoiceAddressId', 'InvoiceDate', 'OrderId', 'CustomerId', 'ParentId', 'TypeId', 'StatusId', 'CurrencyId', 'CurrencyRate', 'TotalPrice', 'TotalPriceWithTax', 'DiscountWithoutTax', 'DiscountWithTax', 'AllowPartialUse', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', 'OrderIdVersion', 'CustomerIdVersion', 'ParentIdVersion', 'CreditNoteIds', 'CreditNoteVersions', ),
self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'invoiceRef', 'invoiceAddressId', 'invoiceDate', 'orderId', 'customerId', 'parentId', 'typeId', 'statusId', 'currencyId', 'currencyRate', 'totalPrice', 'totalPriceWithTax', 'discountWithoutTax', 'discountWithTax', 'allowPartialUse', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', 'orderIdVersion', 'customerIdVersion', 'parentIdVersion', 'creditNoteIds', 'creditNoteVersions', ),
self::TYPE_COLNAME => array(CreditNoteVersionTableMap::ID, CreditNoteVersionTableMap::REF, CreditNoteVersionTableMap::INVOICE_REF, CreditNoteVersionTableMap::INVOICE_ADDRESS_ID, CreditNoteVersionTableMap::INVOICE_DATE, CreditNoteVersionTableMap::ORDER_ID, CreditNoteVersionTableMap::CUSTOMER_ID, CreditNoteVersionTableMap::PARENT_ID, CreditNoteVersionTableMap::TYPE_ID, CreditNoteVersionTableMap::STATUS_ID, CreditNoteVersionTableMap::CURRENCY_ID, CreditNoteVersionTableMap::CURRENCY_RATE, CreditNoteVersionTableMap::TOTAL_PRICE, CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX, CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX, CreditNoteVersionTableMap::DISCOUNT_WITH_TAX, CreditNoteVersionTableMap::ALLOW_PARTIAL_USE, CreditNoteVersionTableMap::CREATED_AT, CreditNoteVersionTableMap::UPDATED_AT, CreditNoteVersionTableMap::VERSION, CreditNoteVersionTableMap::VERSION_CREATED_AT, CreditNoteVersionTableMap::VERSION_CREATED_BY, CreditNoteVersionTableMap::ORDER_ID_VERSION, CreditNoteVersionTableMap::CUSTOMER_ID_VERSION, CreditNoteVersionTableMap::PARENT_ID_VERSION, CreditNoteVersionTableMap::CREDIT_NOTE_IDS, CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS, ),
self::TYPE_RAW_COLNAME => array('ID', 'REF', 'INVOICE_REF', 'INVOICE_ADDRESS_ID', 'INVOICE_DATE', 'ORDER_ID', 'CUSTOMER_ID', 'PARENT_ID', 'TYPE_ID', 'STATUS_ID', 'CURRENCY_ID', 'CURRENCY_RATE', 'TOTAL_PRICE', 'TOTAL_PRICE_WITH_TAX', 'DISCOUNT_WITHOUT_TAX', 'DISCOUNT_WITH_TAX', 'ALLOW_PARTIAL_USE', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', 'ORDER_ID_VERSION', 'CUSTOMER_ID_VERSION', 'PARENT_ID_VERSION', 'CREDIT_NOTE_IDS', 'CREDIT_NOTE_VERSIONS', ),
self::TYPE_FIELDNAME => array('id', 'ref', 'invoice_ref', 'invoice_address_id', 'invoice_date', 'order_id', 'customer_id', 'parent_id', 'type_id', 'status_id', 'currency_id', 'currency_rate', 'total_price', 'total_price_with_tax', 'discount_without_tax', 'discount_with_tax', 'allow_partial_use', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', 'order_id_version', 'customer_id_version', 'parent_id_version', 'credit_note_ids', 'credit_note_versions', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'InvoiceRef' => 2, 'InvoiceAddressId' => 3, 'InvoiceDate' => 4, 'OrderId' => 5, 'CustomerId' => 6, 'ParentId' => 7, 'TypeId' => 8, 'StatusId' => 9, 'CurrencyId' => 10, 'CurrencyRate' => 11, 'TotalPrice' => 12, 'TotalPriceWithTax' => 13, 'DiscountWithoutTax' => 14, 'DiscountWithTax' => 15, 'AllowPartialUse' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, 'Version' => 19, 'VersionCreatedAt' => 20, 'VersionCreatedBy' => 21, 'OrderIdVersion' => 22, 'CustomerIdVersion' => 23, 'ParentIdVersion' => 24, 'CreditNoteIds' => 25, 'CreditNoteVersions' => 26, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'invoiceRef' => 2, 'invoiceAddressId' => 3, 'invoiceDate' => 4, 'orderId' => 5, 'customerId' => 6, 'parentId' => 7, 'typeId' => 8, 'statusId' => 9, 'currencyId' => 10, 'currencyRate' => 11, 'totalPrice' => 12, 'totalPriceWithTax' => 13, 'discountWithoutTax' => 14, 'discountWithTax' => 15, 'allowPartialUse' => 16, 'createdAt' => 17, 'updatedAt' => 18, 'version' => 19, 'versionCreatedAt' => 20, 'versionCreatedBy' => 21, 'orderIdVersion' => 22, 'customerIdVersion' => 23, 'parentIdVersion' => 24, 'creditNoteIds' => 25, 'creditNoteVersions' => 26, ),
self::TYPE_COLNAME => array(CreditNoteVersionTableMap::ID => 0, CreditNoteVersionTableMap::REF => 1, CreditNoteVersionTableMap::INVOICE_REF => 2, CreditNoteVersionTableMap::INVOICE_ADDRESS_ID => 3, CreditNoteVersionTableMap::INVOICE_DATE => 4, CreditNoteVersionTableMap::ORDER_ID => 5, CreditNoteVersionTableMap::CUSTOMER_ID => 6, CreditNoteVersionTableMap::PARENT_ID => 7, CreditNoteVersionTableMap::TYPE_ID => 8, CreditNoteVersionTableMap::STATUS_ID => 9, CreditNoteVersionTableMap::CURRENCY_ID => 10, CreditNoteVersionTableMap::CURRENCY_RATE => 11, CreditNoteVersionTableMap::TOTAL_PRICE => 12, CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX => 13, CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX => 14, CreditNoteVersionTableMap::DISCOUNT_WITH_TAX => 15, CreditNoteVersionTableMap::ALLOW_PARTIAL_USE => 16, CreditNoteVersionTableMap::CREATED_AT => 17, CreditNoteVersionTableMap::UPDATED_AT => 18, CreditNoteVersionTableMap::VERSION => 19, CreditNoteVersionTableMap::VERSION_CREATED_AT => 20, CreditNoteVersionTableMap::VERSION_CREATED_BY => 21, CreditNoteVersionTableMap::ORDER_ID_VERSION => 22, CreditNoteVersionTableMap::CUSTOMER_ID_VERSION => 23, CreditNoteVersionTableMap::PARENT_ID_VERSION => 24, CreditNoteVersionTableMap::CREDIT_NOTE_IDS => 25, CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS => 26, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'INVOICE_REF' => 2, 'INVOICE_ADDRESS_ID' => 3, 'INVOICE_DATE' => 4, 'ORDER_ID' => 5, 'CUSTOMER_ID' => 6, 'PARENT_ID' => 7, 'TYPE_ID' => 8, 'STATUS_ID' => 9, 'CURRENCY_ID' => 10, 'CURRENCY_RATE' => 11, 'TOTAL_PRICE' => 12, 'TOTAL_PRICE_WITH_TAX' => 13, 'DISCOUNT_WITHOUT_TAX' => 14, 'DISCOUNT_WITH_TAX' => 15, 'ALLOW_PARTIAL_USE' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, 'VERSION' => 19, 'VERSION_CREATED_AT' => 20, 'VERSION_CREATED_BY' => 21, 'ORDER_ID_VERSION' => 22, 'CUSTOMER_ID_VERSION' => 23, 'PARENT_ID_VERSION' => 24, 'CREDIT_NOTE_IDS' => 25, 'CREDIT_NOTE_VERSIONS' => 26, ),
self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'invoice_ref' => 2, 'invoice_address_id' => 3, 'invoice_date' => 4, 'order_id' => 5, 'customer_id' => 6, 'parent_id' => 7, 'type_id' => 8, 'status_id' => 9, 'currency_id' => 10, 'currency_rate' => 11, 'total_price' => 12, 'total_price_with_tax' => 13, 'discount_without_tax' => 14, 'discount_with_tax' => 15, 'allow_partial_use' => 16, 'created_at' => 17, 'updated_at' => 18, 'version' => 19, 'version_created_at' => 20, 'version_created_by' => 21, 'order_id_version' => 22, 'customer_id_version' => 23, 'parent_id_version' => 24, 'credit_note_ids' => 25, 'credit_note_versions' => 26, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('credit_note_version');
$this->setPhpName('CreditNoteVersion');
$this->setClassName('\\CreditNote\\Model\\CreditNoteVersion');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'credit_note', 'ID', true, null, null);
$this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null);
$this->addColumn('INVOICE_REF', 'InvoiceRef', 'VARCHAR', false, 45, null);
$this->addColumn('INVOICE_ADDRESS_ID', 'InvoiceAddressId', 'INTEGER', true, null, null);
$this->addColumn('INVOICE_DATE', 'InvoiceDate', 'TIMESTAMP', false, null, null);
$this->addColumn('ORDER_ID', 'OrderId', 'INTEGER', false, null, null);
$this->addColumn('CUSTOMER_ID', 'CustomerId', 'INTEGER', true, null, null);
$this->addColumn('PARENT_ID', 'ParentId', 'INTEGER', false, null, null);
$this->addColumn('TYPE_ID', 'TypeId', 'INTEGER', true, null, null);
$this->addColumn('STATUS_ID', 'StatusId', 'INTEGER', true, null, null);
$this->addColumn('CURRENCY_ID', 'CurrencyId', 'INTEGER', true, null, null);
$this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', false, null, null);
$this->addColumn('TOTAL_PRICE', 'TotalPrice', 'DECIMAL', false, 16, 0);
$this->addColumn('TOTAL_PRICE_WITH_TAX', 'TotalPriceWithTax', 'DECIMAL', false, 16, 0);
$this->addColumn('DISCOUNT_WITHOUT_TAX', 'DiscountWithoutTax', 'DECIMAL', false, 16, 0);
$this->addColumn('DISCOUNT_WITH_TAX', 'DiscountWithTax', 'DECIMAL', false, 16, 0);
$this->addColumn('ALLOW_PARTIAL_USE', 'AllowPartialUse', 'BOOLEAN', false, 1, true);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
$this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
$this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
$this->addColumn('ORDER_ID_VERSION', 'OrderIdVersion', 'INTEGER', false, null, 0);
$this->addColumn('CUSTOMER_ID_VERSION', 'CustomerIdVersion', 'INTEGER', false, null, 0);
$this->addColumn('PARENT_ID_VERSION', 'ParentIdVersion', 'INTEGER', false, null, 0);
$this->addColumn('CREDIT_NOTE_IDS', 'CreditNoteIds', 'ARRAY', false, null, null);
$this->addColumn('CREDIT_NOTE_VERSIONS', 'CreditNoteVersions', 'ARRAY', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
} // buildRelations()
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by find*()
* and findPk*() calls.
*
* @param \CreditNote\Model\CreditNoteVersion $obj A \CreditNote\Model\CreditNoteVersion object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool($obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if (null === $key) {
$key = serialize(array((string) $obj->getId(), (string) $obj->getVersion()));
} // if key === null
self::$instances[$key] = $obj;
}
}
/**
* Removes an object from the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doDelete
* methods in your stub classes -- you may need to explicitly remove objects
* from the cache in order to prevent returning objects that no longer exist.
*
* @param mixed $value A \CreditNote\Model\CreditNoteVersion object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && null !== $value) {
if (is_object($value) && $value instanceof \CreditNote\Model\CreditNoteVersion) {
$key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
} elseif (is_array($value) && count($value) === 2) {
// assume we've been passed a primary key";
$key = serialize(array((string) $value[0], (string) $value[1]));
} elseif ($value instanceof Criteria) {
self::$instances = [];
return;
} else {
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\CreditNoteVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
throw $e;
}
unset(self::$instances[$key]);
}
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 19 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 19 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return $pks;
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? CreditNoteVersionTableMap::CLASS_DEFAULT : CreditNoteVersionTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (CreditNoteVersion object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = CreditNoteVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = CreditNoteVersionTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + CreditNoteVersionTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = CreditNoteVersionTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
CreditNoteVersionTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = CreditNoteVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = CreditNoteVersionTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
CreditNoteVersionTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(CreditNoteVersionTableMap::ID);
$criteria->addSelectColumn(CreditNoteVersionTableMap::REF);
$criteria->addSelectColumn(CreditNoteVersionTableMap::INVOICE_REF);
$criteria->addSelectColumn(CreditNoteVersionTableMap::INVOICE_ADDRESS_ID);
$criteria->addSelectColumn(CreditNoteVersionTableMap::INVOICE_DATE);
$criteria->addSelectColumn(CreditNoteVersionTableMap::ORDER_ID);
$criteria->addSelectColumn(CreditNoteVersionTableMap::CUSTOMER_ID);
$criteria->addSelectColumn(CreditNoteVersionTableMap::PARENT_ID);
$criteria->addSelectColumn(CreditNoteVersionTableMap::TYPE_ID);
$criteria->addSelectColumn(CreditNoteVersionTableMap::STATUS_ID);
$criteria->addSelectColumn(CreditNoteVersionTableMap::CURRENCY_ID);
$criteria->addSelectColumn(CreditNoteVersionTableMap::CURRENCY_RATE);
$criteria->addSelectColumn(CreditNoteVersionTableMap::TOTAL_PRICE);
$criteria->addSelectColumn(CreditNoteVersionTableMap::TOTAL_PRICE_WITH_TAX);
$criteria->addSelectColumn(CreditNoteVersionTableMap::DISCOUNT_WITHOUT_TAX);
$criteria->addSelectColumn(CreditNoteVersionTableMap::DISCOUNT_WITH_TAX);
$criteria->addSelectColumn(CreditNoteVersionTableMap::ALLOW_PARTIAL_USE);
$criteria->addSelectColumn(CreditNoteVersionTableMap::CREATED_AT);
$criteria->addSelectColumn(CreditNoteVersionTableMap::UPDATED_AT);
$criteria->addSelectColumn(CreditNoteVersionTableMap::VERSION);
$criteria->addSelectColumn(CreditNoteVersionTableMap::VERSION_CREATED_AT);
$criteria->addSelectColumn(CreditNoteVersionTableMap::VERSION_CREATED_BY);
$criteria->addSelectColumn(CreditNoteVersionTableMap::ORDER_ID_VERSION);
$criteria->addSelectColumn(CreditNoteVersionTableMap::CUSTOMER_ID_VERSION);
$criteria->addSelectColumn(CreditNoteVersionTableMap::PARENT_ID_VERSION);
$criteria->addSelectColumn(CreditNoteVersionTableMap::CREDIT_NOTE_IDS);
$criteria->addSelectColumn(CreditNoteVersionTableMap::CREDIT_NOTE_VERSIONS);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.REF');
$criteria->addSelectColumn($alias . '.INVOICE_REF');
$criteria->addSelectColumn($alias . '.INVOICE_ADDRESS_ID');
$criteria->addSelectColumn($alias . '.INVOICE_DATE');
$criteria->addSelectColumn($alias . '.ORDER_ID');
$criteria->addSelectColumn($alias . '.CUSTOMER_ID');
$criteria->addSelectColumn($alias . '.PARENT_ID');
$criteria->addSelectColumn($alias . '.TYPE_ID');
$criteria->addSelectColumn($alias . '.STATUS_ID');
$criteria->addSelectColumn($alias . '.CURRENCY_ID');
$criteria->addSelectColumn($alias . '.CURRENCY_RATE');
$criteria->addSelectColumn($alias . '.TOTAL_PRICE');
$criteria->addSelectColumn($alias . '.TOTAL_PRICE_WITH_TAX');
$criteria->addSelectColumn($alias . '.DISCOUNT_WITHOUT_TAX');
$criteria->addSelectColumn($alias . '.DISCOUNT_WITH_TAX');
$criteria->addSelectColumn($alias . '.ALLOW_PARTIAL_USE');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
$criteria->addSelectColumn($alias . '.VERSION');
$criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
$criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
$criteria->addSelectColumn($alias . '.ORDER_ID_VERSION');
$criteria->addSelectColumn($alias . '.CUSTOMER_ID_VERSION');
$criteria->addSelectColumn($alias . '.PARENT_ID_VERSION');
$criteria->addSelectColumn($alias . '.CREDIT_NOTE_IDS');
$criteria->addSelectColumn($alias . '.CREDIT_NOTE_VERSIONS');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(CreditNoteVersionTableMap::DATABASE_NAME)->getTable(CreditNoteVersionTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(CreditNoteVersionTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(CreditNoteVersionTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new CreditNoteVersionTableMap());
}
}
/**
* Performs a DELETE on the database, given a CreditNoteVersion or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CreditNoteVersion object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteVersionTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\CreditNoteVersion) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CreditNoteVersionTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(CreditNoteVersionTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(CreditNoteVersionTableMap::VERSION, $value[1]));
$criteria->addOr($criterion);
}
}
$query = CreditNoteVersionQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CreditNoteVersionTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CreditNoteVersionTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the credit_note_version table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return CreditNoteVersionQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a CreditNoteVersion or Criteria object.
*
* @param mixed $criteria Criteria or CreditNoteVersion object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CreditNoteVersionTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from CreditNoteVersion object
}
// Set the correct dbName
$query = CreditNoteVersionQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // CreditNoteVersionTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
CreditNoteVersionTableMap::buildTableMap();

View File

@@ -0,0 +1,504 @@
<?php
namespace CreditNote\Model\Map;
use CreditNote\Model\OrderCreditNote;
use CreditNote\Model\OrderCreditNoteQuery;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
/**
* This class defines the structure of the 'order_credit_note' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class OrderCreditNoteTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'CreditNote.Model.Map.OrderCreditNoteTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'order_credit_note';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\CreditNote\\Model\\OrderCreditNote';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'CreditNote.Model.OrderCreditNote';
/**
* The total number of columns
*/
const NUM_COLUMNS = 5;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 5;
/**
* the column name for the ORDER_ID field
*/
const ORDER_ID = 'order_credit_note.ORDER_ID';
/**
* the column name for the CREDIT_NOTE_ID field
*/
const CREDIT_NOTE_ID = 'order_credit_note.CREDIT_NOTE_ID';
/**
* the column name for the AMOUNT_PRICE field
*/
const AMOUNT_PRICE = 'order_credit_note.AMOUNT_PRICE';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'order_credit_note.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'order_credit_note.UPDATED_AT';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('OrderId', 'CreditNoteId', 'AmountPrice', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('orderId', 'creditNoteId', 'amountPrice', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(OrderCreditNoteTableMap::ORDER_ID, OrderCreditNoteTableMap::CREDIT_NOTE_ID, OrderCreditNoteTableMap::AMOUNT_PRICE, OrderCreditNoteTableMap::CREATED_AT, OrderCreditNoteTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ORDER_ID', 'CREDIT_NOTE_ID', 'AMOUNT_PRICE', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('order_id', 'credit_note_id', 'amount_price', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('OrderId' => 0, 'CreditNoteId' => 1, 'AmountPrice' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
self::TYPE_STUDLYPHPNAME => array('orderId' => 0, 'creditNoteId' => 1, 'amountPrice' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
self::TYPE_COLNAME => array(OrderCreditNoteTableMap::ORDER_ID => 0, OrderCreditNoteTableMap::CREDIT_NOTE_ID => 1, OrderCreditNoteTableMap::AMOUNT_PRICE => 2, OrderCreditNoteTableMap::CREATED_AT => 3, OrderCreditNoteTableMap::UPDATED_AT => 4, ),
self::TYPE_RAW_COLNAME => array('ORDER_ID' => 0, 'CREDIT_NOTE_ID' => 1, 'AMOUNT_PRICE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
self::TYPE_FIELDNAME => array('order_id' => 0, 'credit_note_id' => 1, 'amount_price' => 2, 'created_at' => 3, 'updated_at' => 4, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
);
/**
* Initialize the table attributes and columns
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
$this->setName('order_credit_note');
$this->setPhpName('OrderCreditNote');
$this->setClassName('\\CreditNote\\Model\\OrderCreditNote');
$this->setPackage('CreditNote.Model');
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ORDER_ID', 'OrderId', 'INTEGER' , 'order', 'ID', true, null, null);
$this->addForeignPrimaryKey('CREDIT_NOTE_ID', 'CreditNoteId', 'INTEGER' , 'credit_note', 'ID', true, null, null);
$this->addColumn('AMOUNT_PRICE', 'AmountPrice', 'DECIMAL', false, 16, 0);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{
$this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
$this->addRelation('CreditNote', '\\CreditNote\\Model\\CreditNote', RelationMap::MANY_TO_ONE, array('credit_note_id' => 'id', ), 'CASCADE', 'RESTRICT');
} // buildRelations()
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
);
} // getBehaviors()
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by find*()
* and findPk*() calls.
*
* @param \CreditNote\Model\OrderCreditNote $obj A \CreditNote\Model\OrderCreditNote object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool($obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if (null === $key) {
$key = serialize(array((string) $obj->getOrderId(), (string) $obj->getCreditNoteId()));
} // if key === null
self::$instances[$key] = $obj;
}
}
/**
* Removes an object from the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doDelete
* methods in your stub classes -- you may need to explicitly remove objects
* from the cache in order to prevent returning objects that no longer exist.
*
* @param mixed $value A \CreditNote\Model\OrderCreditNote object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && null !== $value) {
if (is_object($value) && $value instanceof \CreditNote\Model\OrderCreditNote) {
$key = serialize(array((string) $value->getOrderId(), (string) $value->getCreditNoteId()));
} elseif (is_array($value) && count($value) === 2) {
// assume we've been passed a primary key";
$key = serialize(array((string) $value[0], (string) $value[1]));
} elseif ($value instanceof Criteria) {
self::$instances = [];
return;
} else {
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \CreditNote\Model\OrderCreditNote object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
throw $e;
}
unset(self::$instances[$key]);
}
}
/**
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
*
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, a serialize()d version of the primary key will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*/
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
// If the PK cannot be derived from the row, return NULL.
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
return null;
}
return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CreditNoteId', TableMap::TYPE_PHPNAME, $indexType)]));
}
/**
* Retrieves the primary key from the DB resultset row
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
* a multi-column primary key, an array of the primary key columns will be returned.
*
* @param array $row resultset row.
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
*
* @return mixed The primary key of the row
*/
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
return $pks;
}
/**
* The class that the tableMap will make instances of.
*
* If $withPrefix is true, the returned path
* uses a dot-path notation which is translated into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @param boolean $withPrefix Whether or not to return the path with the class name
* @return string path.to.ClassName
*/
public static function getOMClass($withPrefix = true)
{
return $withPrefix ? OrderCreditNoteTableMap::CLASS_DEFAULT : OrderCreditNoteTableMap::OM_CLASS;
}
/**
* Populates an object of the default type or an object that inherit from the default.
*
* @param array $row row returned by DataFetcher->fetch().
* @param int $offset The 0-based offset for reading from the resultset row.
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return array (OrderCreditNote object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = OrderCreditNoteTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = OrderCreditNoteTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, $offset, true); // rehydrate
$col = $offset + OrderCreditNoteTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = OrderCreditNoteTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
OrderCreditNoteTableMap::addInstanceToPool($obj, $key);
}
return array($obj, $col);
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @param DataFetcherInterface $dataFetcher
* @return array
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(DataFetcherInterface $dataFetcher)
{
$results = array();
// set the class once to avoid overhead in the loop
$cls = static::getOMClass(false);
// populate the object(s)
while ($row = $dataFetcher->fetch()) {
$key = OrderCreditNoteTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = OrderCreditNoteTableMap::getInstanceFromPool($key))) {
// We no longer rehydrate the object, since this can cause data loss.
// See http://www.propelorm.org/ticket/509
// $obj->hydrate($row, 0, true); // rehydrate
$results[] = $obj;
} else {
$obj = new $cls();
$obj->hydrate($row);
$results[] = $obj;
OrderCreditNoteTableMap::addInstanceToPool($obj, $key);
} // if key exists
}
return $results;
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param Criteria $criteria object containing the columns to add.
* @param string $alias optional table alias
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(OrderCreditNoteTableMap::ORDER_ID);
$criteria->addSelectColumn(OrderCreditNoteTableMap::CREDIT_NOTE_ID);
$criteria->addSelectColumn(OrderCreditNoteTableMap::AMOUNT_PRICE);
$criteria->addSelectColumn(OrderCreditNoteTableMap::CREATED_AT);
$criteria->addSelectColumn(OrderCreditNoteTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ORDER_ID');
$criteria->addSelectColumn($alias . '.CREDIT_NOTE_ID');
$criteria->addSelectColumn($alias . '.AMOUNT_PRICE');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}
}
/**
* Returns the TableMap related to this object.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getServiceContainer()->getDatabaseMap(OrderCreditNoteTableMap::DATABASE_NAME)->getTable(OrderCreditNoteTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderCreditNoteTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(OrderCreditNoteTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new OrderCreditNoteTableMap());
}
}
/**
* Performs a DELETE on the database, given a OrderCreditNote or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or OrderCreditNote object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CreditNote\Model\OrderCreditNote) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(OrderCreditNoteTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(OrderCreditNoteTableMap::ORDER_ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(OrderCreditNoteTableMap::CREDIT_NOTE_ID, $value[1]));
$criteria->addOr($criterion);
}
}
$query = OrderCreditNoteQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { OrderCreditNoteTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { OrderCreditNoteTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the order_credit_note table.
*
* @param ConnectionInterface $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll(ConnectionInterface $con = null)
{
return OrderCreditNoteQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a OrderCreditNote or Criteria object.
*
* @param mixed $criteria Criteria or OrderCreditNote object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(OrderCreditNoteTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from OrderCreditNote object
}
// Set the correct dbName
$query = OrderCreditNoteQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}
} // OrderCreditNoteTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
OrderCreditNoteTableMap::buildTableMap();

View File

@@ -0,0 +1,10 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\OrderCreditNote as BaseOrderCreditNote;
class OrderCreditNote extends BaseOrderCreditNote
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace CreditNote\Model;
use CreditNote\Model\Base\OrderCreditNoteQuery as BaseOrderCreditNoteQuery;
/**
* Skeleton subclass for performing query and update operations on the 'order_credit_note' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class OrderCreditNoteQuery extends BaseOrderCreditNoteQuery
{
} // OrderCreditNoteQuery

View File

@@ -0,0 +1,143 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Model\Tools;
use CreditNote\Event\PropelEvent;
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Tools\ModelEventDispatcherTrait as TheliaModelEventDispatcherTrait;
use CreditNote\Event\CreditNoteEvents;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
trait ModelEventDispatcherTrait
{
use TheliaModelEventDispatcherTrait;
protected function getTableName()
{
$tableMapClass = self::TABLE_MAP;
return $tableMapClass::TABLE_NAME;
}
/**
* Code to be run before inserting to database
* @param ConnectionInterface $con
* @return boolean
*/
public function preInsert(ConnectionInterface $con = null)
{
parent::preInsert($con);
if ($this->getDispatcher() !== null) {
/** @var ActiveRecordInterface $this */
$event = new PropelEvent($this);
/** @var ModelEventDispatcherTrait $this */
$this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_PRE_INSERT . $this->getTableName(), $event);
if ($event->isPropagationStopped()) {
return false;
}
}
return true;
}
/**
* Code to be run after inserting to database
* @param ConnectionInterface $con
*/
public function postInsert(ConnectionInterface $con = null)
{
parent::postInsert($con);
if ($this->getDispatcher() !== null) {
/** @var ActiveRecordInterface $this */
$event = new PropelEvent($this);
/** @var ModelEventDispatcherTrait $this */
$this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_POST_INSERT . $this->getTableName(), $event);
}
}
/**
* Code to be run before updating the object in database
* @param ConnectionInterface $con
* @return boolean
*/
public function preUpdate(ConnectionInterface $con = null)
{
parent::preUpdate($con);
if ($this->getDispatcher() !== null) {
/** @var ActiveRecordInterface $this */
$event = new PropelEvent($this);
/** @var ModelEventDispatcherTrait $this */
$this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_PRE_UPDATE . $this->getTableName(), $event);
if ($event->isPropagationStopped()) {
return false;
}
}
return true;
}
/**
* Code to be run after updating the object in database
* @param ConnectionInterface $con
*/
public function postUpdate(ConnectionInterface $con = null)
{
parent::postUpdate($con);
if ($this->getDispatcher() !== null) {
/** @var ActiveRecordInterface $this */
$event = new PropelEvent($this);
/** @var ModelEventDispatcherTrait $this */
$this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_POST_UPDATE . $this->getTableName(), $event);
}
}
/**
* Code to be run before deleting the object in database
* @param ConnectionInterface $con
* @return boolean
*/
public function preDelete(ConnectionInterface $con = null)
{
parent::preDelete($con);
if ($this->getDispatcher() !== null) {
/** @var ActiveRecordInterface $this */
$event = new PropelEvent($this);
/** @var ModelEventDispatcherTrait $this */
$this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_PRE_DELETE . $this->getTableName(), $event);
if ($event->isPropagationStopped()) {
return false;
}
}
return true;
}
/**
* Code to be run after deleting the object in database
* @param ConnectionInterface $con
*/
public function postDelete(ConnectionInterface $con = null)
{
parent::postDelete($con);
if ($this->getDispatcher() !== null) {
/** @var ActiveRecordInterface $this */
$event = new PropelEvent($this);
/** @var ModelEventDispatcherTrait $this */
$this->getDispatcher()->dispatch(CreditNoteEvents::PROPEL_POST_DELETE . $this->getTableName(), $event);
}
}
}

View File

@@ -0,0 +1,24 @@
# Credit Note
Author: Gilles Bourgeat <gilles.bourgeat@gmail.com>
* Allows granting credit notes to customers
## Compatibility
Thelia >= 2.3
## Installation
### Manually
* Copy the module into ```<thelia_root>/local/modules/``` directory and be sure that the name of the module is ```CreditNote```.
* Activate it in your thelia administration panel
### Composer
Add it in your main thelia composer.json file
```
composer require thelia/credit-note-module:~2.3.0
```

View File

@@ -0,0 +1,164 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Smarty\Plugins;
use CommerceGuys\Addressing\Model\Address;
use CreditNote\Model\CreditNoteAddressQuery;
use CreditNote\Model\CreditNoteQuery;
use Symfony\Component\DependencyInjection\Container;
use Thelia\Tools\AddressFormat;
use Symfony\Component\HttpFoundation\RequestStack;
use TheliaSmarty\Template\AbstractSmartyPlugin;
use TheliaSmarty\Template\Exception\SmartyPluginException;
use TheliaSmarty\Template\SmartyPluginDescriptor;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class CreditNoteFormat extends AbstractSmartyPlugin
{
/** @var RequestStack */
protected $requestStack;
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
/**
*
* display an address in expected format
*
* available parameters :
* address => the id of the address to display
* order_address => the id of the order address to display
* from_country_id => the country id
* dec_point => separator for the decimal point
* thousands_sep => thousands separator
* symbol => Currency symbol
*
* ex : {format_money number="1246.12" decimals="1" dec_point="," thousands_sep=" " symbol="€"} will output "1 246,1 €"
*
* @param $params
* @param null $template
* @throws \TheliaSmarty\Template\Exception\SmartyPluginException
* @return string the expected number formatted
*/
public function formatAddress($params, $template = null)
{
$postal = filter_var(
$this->getParam($params, "postal", null),
FILTER_VALIDATE_BOOLEAN
);
$html = filter_var(
$this->getParam($params, "html", true),
FILTER_VALIDATE_BOOLEAN
);
$htmlTag = $this->getParam($params, "html_tag", "p");
$originCountry = $this->getParam($params, "origin_country", null);
$locale = $this->getParam($params, "locale", $this->getSession()->getLang()->getLocale());
// extract html attributes
$htmlAttributes = [];
foreach ($params as $k => $v) {
if (strpos($k, 'html_') !== false && $k !== 'html_tag') {
$htmlAttributes[substr($k, 5)] = $v;
}
}
// get address or order address
$address = null;
if (null !== $id = $this->getParam($params, "credit_note_id", null)) {
if (null === $address = CreditNoteAddressQuery::create()->findOneById(
CreditNoteQuery::create()->findOneById($id)->getInvoiceAddressId()
)
) {
return '';
}
} else {
// try to parse arguments to build address
$address = $this->getAddressFormParams($params);
}
if (null === $address) {
throw new SmartyPluginException(
"Either address, order_address or full list of address fields should be provided"
);
}
$addressFormat = AddressFormat::getInstance();
if ($postal) {
if ($address instanceof Address) {
$formattedAddress = $addressFormat->postalLabelFormat($address, $locale, $originCountry);
} else {
$formattedAddress = $addressFormat->postalLabelFormatTheliaAddress($address, $locale, $originCountry);
}
} else {
if ($address instanceof Address) {
$formattedAddress = $addressFormat->format($address, $locale, $html, $htmlTag, $htmlAttributes);
} else {
$formattedAddress = $addressFormat->formatTheliaAddress($address, $locale, $html, $htmlTag, $htmlAttributes);
}
}
return $formattedAddress;
}
protected function getAddressFormParams($params)
{
// Check if there is arguments
$addressArgs = [
'country_code',
'administrative_area',
'locality',
'dependent_locality',
'postal_code',
'sorting_code',
'address_line1',
'address_line2',
'organization',
'recipient',
'locale'
];
$valid = false;
$address = new Address();
foreach ($addressArgs as $arg) {
if (null !== $argVal = $this->getParam($params, $arg, null)) {
$valid = true;
$functionName = 'with' . Container::camelize($arg);
$address = $address->$functionName($argVal);
}
}
if (false === $valid) {
return null;
}
return $address;
}
/**
* @return SmartyPluginDescriptor[]
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor("function", "credit_note_format_address", $this, "formatAddress"),
);
}
protected function getSession()
{
return $this->requestStack->getCurrentRequest()->getSession();
}
}

Some files were not shown because too many files have changed in this diff Show More