From 95031f4f4c3fe2ebf7492ba9647d691096b71899 Mon Sep 17 00:00:00 2001 From: Admin Date: Tue, 6 Mar 2018 16:43:36 +0100 Subject: [PATCH 1/3] Add part Company name --- Config/module.xml | 2 +- Config/schema.xml | 1 + Config/thelia.sql | 1 + Form/CustomerCustomerFamilyForm.php | 13 +++++++++++++ I18n/en_US.php | 1 + I18n/fr_FR.php | 1 + templates/backOffice/default/customer-edit.html | 14 ++++++++++++++ 7 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Config/module.xml b/Config/module.xml index 736c46e..b0ce372 100755 --- a/Config/module.xml +++ b/Config/module.xml @@ -7,7 +7,7 @@ Famille de clients et prix d'achat - 1.3.13 + 1.3.14 Guillaume Barral / Etienne Perriere gbarral@openstudio.fr / eperriere@openstudio.fr diff --git a/Config/schema.xml b/Config/schema.xml index 9883bb0..45c605a 100755 --- a/Config/schema.xml +++ b/Config/schema.xml @@ -18,6 +18,7 @@ + diff --git a/Config/thelia.sql b/Config/thelia.sql index 49e4387..8a7a197 100755 --- a/Config/thelia.sql +++ b/Config/thelia.sql @@ -30,6 +30,7 @@ CREATE TABLE `customer_customer_family` ( `customer_id` INTEGER NOT NULL, `customer_family_id` INTEGER NOT NULL, + `company_name` VARCHAR(250), `siret` VARCHAR(50), `vat` VARCHAR(50), PRIMARY KEY (`customer_id`), diff --git a/Form/CustomerCustomerFamilyForm.php b/Form/CustomerCustomerFamilyForm.php index 6771de6..38ddc36 100755 --- a/Form/CustomerCustomerFamilyForm.php +++ b/Form/CustomerCustomerFamilyForm.php @@ -85,6 +85,19 @@ protected function buildForm() 'for' => 'customer_id' ) )) + ->add('company_name','text', array( + 'constraints' => array( + new Constraints\NotBlank() + ), + 'label' => Translator::getInstance()->trans( + 'Company name', + array(), + CustomerFamily::MESSAGE_DOMAIN + ), + 'label_attr' => array( + 'for' => 'company_name' + ) + )) ->add( 'siret', 'text', diff --git a/I18n/en_US.php b/I18n/en_US.php index e00d3ff..f2e556d 100755 --- a/I18n/en_US.php +++ b/I18n/en_US.php @@ -2,6 +2,7 @@ return array( //C "Customer family" => "Customer family", + "Company name" => "Company name", //F "Family of this customer" => "Customer family", diff --git a/I18n/fr_FR.php b/I18n/fr_FR.php index cf3c290..b080ea6 100755 --- a/I18n/fr_FR.php +++ b/I18n/fr_FR.php @@ -2,6 +2,7 @@ return array( 'Code' => 'Code', + 'Company name' => 'Nom entreprise', 'Customer' => 'Client', 'Customer family' => 'Famille clients', 'Customer family was created successfully' => 'La famille a été créée avec succès', diff --git a/templates/backOffice/default/customer-edit.html b/templates/backOffice/default/customer-edit.html index c23684e..20e9eb8 100755 --- a/templates/backOffice/default/customer-edit.html +++ b/templates/backOffice/default/customer-edit.html @@ -1,5 +1,6 @@ {loop name="customer_customer_family" type="customer_customer_family" customer_id=$customer_id} {assign var="_customer_family_id_" value=$CUSTOMER_FAMILY_ID} + {assign var="_company_name_" value=$COMPANY_NAME} {assign var="_siret_" value=$SIRET} {assign var="_vat_" value=$VAT} {/loop} @@ -34,6 +35,19 @@ {/form_field} + {form_field form=$form field="company_name"} +
+ +
+ + {if $error } + {$message} + {assign var="error_focus" value="true"} + {/if} +
+
+ {/form_field} + {form_field form=$form field="siret"}
From 209971e58fc11bded3a576b90a4cf71eb688ca7b Mon Sep 17 00:00:00 2001 From: Admin Date: Tue, 6 Mar 2018 17:03:43 +0100 Subject: [PATCH 2/3] Add file sql 1.4.0 in Update --- Config/module.xml | 2 +- Config/update/1.4.0.sql | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Config/update/1.4.0.sql diff --git a/Config/module.xml b/Config/module.xml index b0ce372..a560af2 100755 --- a/Config/module.xml +++ b/Config/module.xml @@ -7,7 +7,7 @@ Famille de clients et prix d'achat - 1.3.14 + 1.4.0 Guillaume Barral / Etienne Perriere gbarral@openstudio.fr / eperriere@openstudio.fr diff --git a/Config/update/1.4.0.sql b/Config/update/1.4.0.sql new file mode 100644 index 0000000..83e89c8 --- /dev/null +++ b/Config/update/1.4.0.sql @@ -0,0 +1,5 @@ +SET FOREIGN_KEY_CHECKS = 0; + +ALTER TABLE `customer_customer_family` ADD `company_name` VARCHAR(250) AFTER `customer_family_id`; + +SET FOREIGN_KEY_CHECKS = 1; \ No newline at end of file From 5a017ab9b1370264bcb26416ba944c4035de6516 Mon Sep 17 00:00:00 2001 From: Admin Date: Wed, 7 Mar 2018 12:46:45 +0100 Subject: [PATCH 3/3] Update part 'Company name' --- .../Admin/CustomerFamilyAdminController.php | 1 + Event/CustomerCustomerFamilyEvent.php | 22 ++++++ EventListeners/CustomerFamilyListener.php | 1 + Form/CustomerCustomerFamilyForm.php | 8 +-- Loop/CustomerCustomerFamilyLoop.php | 1 + Model/Base/CustomerCustomerFamily.php | 70 +++++++++++++++++-- Model/Map/CustomerCustomerFamilyTableMap.php | 28 +++++--- .../backOffice/default/customer-edit.html | 4 +- 8 files changed, 113 insertions(+), 22 deletions(-) diff --git a/Controller/Admin/CustomerFamilyAdminController.php b/Controller/Admin/CustomerFamilyAdminController.php index 142fd83..d62ae80 100755 --- a/Controller/Admin/CustomerFamilyAdminController.php +++ b/Controller/Admin/CustomerFamilyAdminController.php @@ -265,6 +265,7 @@ public function customerUpdateAction(Request $request) $event = new CustomerCustomerFamilyEvent($formValidate->get('customer_id')->getData()); $event ->setCustomerFamilyId($formValidate->get('customer_family_id')->getData()) + ->setCompanyName($formValidate->get('company_name')->getData()) ->setSiret($formValidate->get('siret')->getData()) ->setVat($formValidate->get('vat')->getData()) ; diff --git a/Event/CustomerCustomerFamilyEvent.php b/Event/CustomerCustomerFamilyEvent.php index 4063894..ef663a7 100755 --- a/Event/CustomerCustomerFamilyEvent.php +++ b/Event/CustomerCustomerFamilyEvent.php @@ -27,6 +27,9 @@ class CustomerCustomerFamilyEvent extends ActionEvent /** @var int */ protected $customerFamilyId; + /** @var string */ + protected $companyName; + /** @var string */ protected $siret; @@ -81,6 +84,25 @@ public function getCustomerId() return $this->customerId; } + /** + * @param string $companyName + * @return CustomerCustomerFamily + */ + public function setCompanyName($companyName) + { + $this->companyName = $companyName; + + return $this; + } + + /** + * @return mixed + */ + public function getCompanyName() + { + return $this->companyName; + } + /** * @param mixed $siret * diff --git a/EventListeners/CustomerFamilyListener.php b/EventListeners/CustomerFamilyListener.php index 7213cef..9fac0db 100755 --- a/EventListeners/CustomerFamilyListener.php +++ b/EventListeners/CustomerFamilyListener.php @@ -222,6 +222,7 @@ public function customerCustomerFamilyUpdate(CustomerCustomerFamilyEvent $event) $customerCustomerFamily ->setCustomerFamilyId($event->getCustomerFamilyId()) + ->setCompanyName($event->getCompanyName()) ->setSiret($event->getSiret()) ->setVat($event->getVat()) ->save() diff --git a/Form/CustomerCustomerFamilyForm.php b/Form/CustomerCustomerFamilyForm.php index 38ddc36..b342528 100755 --- a/Form/CustomerCustomerFamilyForm.php +++ b/Form/CustomerCustomerFamilyForm.php @@ -87,7 +87,9 @@ protected function buildForm() )) ->add('company_name','text', array( 'constraints' => array( - new Constraints\NotBlank() + new Constraints\Callback(array("methods" => array( + array($this, "checkProfessionalInformation") + ))) ), 'label' => Translator::getInstance()->trans( 'Company name', @@ -99,9 +101,7 @@ protected function buildForm() ) )) ->add( - 'siret', - 'text', - array( + 'siret','text', array( 'constraints' => array( new Constraints\Callback(array("methods" => array( array($this, "checkProfessionalInformation") diff --git a/Loop/CustomerCustomerFamilyLoop.php b/Loop/CustomerCustomerFamilyLoop.php index d8e0d74..622ecde 100755 --- a/Loop/CustomerCustomerFamilyLoop.php +++ b/Loop/CustomerCustomerFamilyLoop.php @@ -88,6 +88,7 @@ public function parseResults(LoopResult $loopResult) $loopResultRow ->set("CUSTOMER_FAMILY_ID", $customerCustomerFamily->getCustomerFamilyId()) ->set("CUSTOMER_ID", $customerCustomerFamily->getCustomerId()) + ->set("COMPANY_NAME", $customerCustomerFamily->getCompanyName()) ->set("SIRET", $customerCustomerFamily->getSiret()) ->set("VAT", $customerCustomerFamily->getVat()) ; diff --git a/Model/Base/CustomerCustomerFamily.php b/Model/Base/CustomerCustomerFamily.php index ad735a7..cac4359 100644 --- a/Model/Base/CustomerCustomerFamily.php +++ b/Model/Base/CustomerCustomerFamily.php @@ -67,6 +67,12 @@ abstract class CustomerCustomerFamily implements ActiveRecordInterface */ protected $customer_family_id; + /** + * The value for the company_name field. + * @var int + */ + protected $company_name; + /** * The value for the siret field. * @var string @@ -377,6 +383,17 @@ public function getCustomerFamilyId() return $this->customer_family_id; } + /** + * Get the [company_name] column value. + * + * @return string + */ + public function getCompanyName() + { + + return $this->company_name; + } + /** * Get the [siret] column value. * @@ -449,6 +466,27 @@ public function setCustomerFamilyId($v) return $this; } // setCustomerFamilyId() + /** + * Set the value of [company_name] column. + * + * @param string $v new value + * @return \CustomerFamily\Model\CustomerCustomerFamily The current object (for fluent API support) + */ + public function setCompanyName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->company_name !== $v) { + $this->company_name = $v; + $this->modifiedColumns[CustomerCustomerFamilyTableMap::COMPANY_NAME] = true; + } + + + return $this; + } // setCompanyName() + /** * Set the value of [siret] column. * @@ -534,6 +572,9 @@ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = Ta $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerCustomerFamilyTableMap::translateFieldName('CustomerFamilyId', TableMap::TYPE_PHPNAME, $indexType)]; $this->customer_family_id = (null !== $col) ? (int) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerCustomerFamilyTableMap::translateFieldName('CompanyName', TableMap::TYPE_PHPNAME, $indexType)]; + $this->company_name = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerCustomerFamilyTableMap::translateFieldName('Siret', TableMap::TYPE_PHPNAME, $indexType)]; $this->siret = (null !== $col) ? (string) $col : null; @@ -785,6 +826,9 @@ protected function doInsert(ConnectionInterface $con) if ($this->isColumnModified(CustomerCustomerFamilyTableMap::CUSTOMER_FAMILY_ID)) { $modifiedColumns[':p' . $index++] = 'CUSTOMER_FAMILY_ID'; } + if ($this->isColumnModified(CustomerCustomerFamilyTableMap::COMPANY_NAME)) { + $modifiedColumns[':p'] = 'COMPANY_NAME'; + } if ($this->isColumnModified(CustomerCustomerFamilyTableMap::SIRET)) { $modifiedColumns[':p' . $index++] = 'SIRET'; } @@ -808,6 +852,9 @@ protected function doInsert(ConnectionInterface $con) case 'CUSTOMER_FAMILY_ID': $stmt->bindValue($identifier, $this->customer_family_id, PDO::PARAM_INT); break; + case 'COMPANY_NAME': + $stmt->bindValue($identifier, $this->company_name, PDO::PARAM_INT); + break; case 'SIRET': $stmt->bindValue($identifier, $this->siret, PDO::PARAM_STR); break; @@ -876,9 +923,12 @@ public function getByPosition($pos) return $this->getCustomerFamilyId(); break; case 2: - return $this->getSiret(); + return $this->getCompanyName(); break; case 3: + return $this->getSiret(); + break; + case 4: return $this->getVat(); break; default: @@ -912,8 +962,9 @@ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColum $result = array( $keys[0] => $this->getCustomerId(), $keys[1] => $this->getCustomerFamilyId(), - $keys[2] => $this->getSiret(), - $keys[3] => $this->getVat(), + $keys[2] => $this->getCompanyName(), + $keys[3] => $this->getSiret(), + $keys[4] => $this->getVat(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -968,9 +1019,12 @@ public function setByPosition($pos, $value) $this->setCustomerFamilyId($value); break; case 2: - $this->setSiret($value); + $this->setCompanyName($value); break; case 3: + $this->setSiret($value); + break; + case 4: $this->setVat($value); break; } // switch() @@ -999,8 +1053,9 @@ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) if (array_key_exists($keys[0], $arr)) $this->setCustomerId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setCustomerFamilyId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setSiret($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setVat($arr[$keys[3]]); + if (array_key_exists($keys[2], $arr)) $this->setCompanyName($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setSiret($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setVat($arr[$keys[4]]); } /** @@ -1014,6 +1069,7 @@ public function buildCriteria() if ($this->isColumnModified(CustomerCustomerFamilyTableMap::CUSTOMER_ID)) $criteria->add(CustomerCustomerFamilyTableMap::CUSTOMER_ID, $this->customer_id); if ($this->isColumnModified(CustomerCustomerFamilyTableMap::CUSTOMER_FAMILY_ID)) $criteria->add(CustomerCustomerFamilyTableMap::CUSTOMER_FAMILY_ID, $this->customer_family_id); + if ($this->isColumnModified(CustomerCustomerFamilyTableMap::COMPANY_NAME)) $criteria->add(CustomerCustomerFamilyTableMap::COMPANY_NAME, $this->company_name); if ($this->isColumnModified(CustomerCustomerFamilyTableMap::SIRET)) $criteria->add(CustomerCustomerFamilyTableMap::SIRET, $this->siret); if ($this->isColumnModified(CustomerCustomerFamilyTableMap::VAT)) $criteria->add(CustomerCustomerFamilyTableMap::VAT, $this->vat); @@ -1081,6 +1137,7 @@ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setCustomerId($this->getCustomerId()); $copyObj->setCustomerFamilyId($this->getCustomerFamilyId()); + $copyObj->setCompanyName($this->getCompanyName()); $copyObj->setSiret($this->getSiret()); $copyObj->setVat($this->getVat()); if ($makeNew) { @@ -1213,6 +1270,7 @@ public function clear() { $this->customer_id = null; $this->customer_family_id = null; + $this->company_name = null; $this->siret = null; $this->vat = null; $this->alreadyInSave = false; diff --git a/Model/Map/CustomerCustomerFamilyTableMap.php b/Model/Map/CustomerCustomerFamilyTableMap.php index 10c4a7d..0027bee 100644 --- a/Model/Map/CustomerCustomerFamilyTableMap.php +++ b/Model/Map/CustomerCustomerFamilyTableMap.php @@ -80,6 +80,11 @@ class CustomerCustomerFamilyTableMap extends TableMap */ const CUSTOMER_FAMILY_ID = 'customer_customer_family.CUSTOMER_FAMILY_ID'; + /** + * the column name for the COMPANY_NAME field + */ + const COMPANY_NAME = 'customer_customer_family.COMPANY_NAME'; + /** * the column name for the SIRET field */ @@ -102,12 +107,12 @@ class CustomerCustomerFamilyTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('CustomerId', 'CustomerFamilyId', 'Siret', 'Vat', ), - self::TYPE_STUDLYPHPNAME => array('customerId', 'customerFamilyId', 'siret', 'vat', ), - self::TYPE_COLNAME => array(CustomerCustomerFamilyTableMap::CUSTOMER_ID, CustomerCustomerFamilyTableMap::CUSTOMER_FAMILY_ID, CustomerCustomerFamilyTableMap::SIRET, CustomerCustomerFamilyTableMap::VAT, ), - self::TYPE_RAW_COLNAME => array('CUSTOMER_ID', 'CUSTOMER_FAMILY_ID', 'SIRET', 'VAT', ), - self::TYPE_FIELDNAME => array('customer_id', 'customer_family_id', 'siret', 'vat', ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('CustomerId', 'CustomerFamilyId','CompanyName', 'Siret', 'Vat', ), + self::TYPE_STUDLYPHPNAME => array('customerId', 'customerFamilyId', 'companyName', 'siret', 'vat', ), + self::TYPE_COLNAME => array(CustomerCustomerFamilyTableMap::CUSTOMER_ID, CustomerCustomerFamilyTableMap::CUSTOMER_FAMILY_ID, CustomerCustomerFamilyTableMap::COMPANY_NAME, CustomerCustomerFamilyTableMap::SIRET, CustomerCustomerFamilyTableMap::VAT, ), + self::TYPE_RAW_COLNAME => array('CUSTOMER_ID', 'CUSTOMER_FAMILY_ID','COMPANY_NAME', 'SIRET', 'VAT', ), + self::TYPE_FIELDNAME => array('customer_id', 'customer_family_id', 'company_name', 'siret', 'vat', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -117,11 +122,11 @@ class CustomerCustomerFamilyTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('CustomerId' => 0, 'CustomerFamilyId' => 1, 'Siret' => 2, 'Vat' => 3, ), + self::TYPE_PHPNAME => array('CustomerId' => 0, 'CustomerFamilyId' => 1, 'CompanyName' => 2, 'Siret' => 3, 'Vat' => 4, ), self::TYPE_STUDLYPHPNAME => array('customerId' => 0, 'customerFamilyId' => 1, 'siret' => 2, 'vat' => 3, ), - self::TYPE_COLNAME => array(CustomerCustomerFamilyTableMap::CUSTOMER_ID => 0, CustomerCustomerFamilyTableMap::CUSTOMER_FAMILY_ID => 1, CustomerCustomerFamilyTableMap::SIRET => 2, CustomerCustomerFamilyTableMap::VAT => 3, ), - self::TYPE_RAW_COLNAME => array('CUSTOMER_ID' => 0, 'CUSTOMER_FAMILY_ID' => 1, 'SIRET' => 2, 'VAT' => 3, ), - self::TYPE_FIELDNAME => array('customer_id' => 0, 'customer_family_id' => 1, 'siret' => 2, 'vat' => 3, ), + self::TYPE_COLNAME => array(CustomerCustomerFamilyTableMap::CUSTOMER_ID => 0, CustomerCustomerFamilyTableMap::CUSTOMER_FAMILY_ID => 1, CustomerCustomerFamilyTableMap::COMPANY_NAME => 2, CustomerCustomerFamilyTableMap::SIRET => 3, CustomerCustomerFamilyTableMap::VAT => 4, ), + self::TYPE_RAW_COLNAME => array('CUSTOMER_ID' => 0, 'CUSTOMER_FAMILY_ID' => 1, 'COMPANY_NAME' => 2, 'SIRET' => 3, 'VAT' => 4, ), + self::TYPE_FIELDNAME => array('customer_id' => 0, 'customer_family_id' => 1, 'company_name' => 2, 'siret' => 3, 'vat' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, ) ); @@ -143,6 +148,7 @@ public function initialize() // columns $this->addForeignPrimaryKey('CUSTOMER_ID', 'CustomerId', 'INTEGER' , 'customer', 'ID', true, null, null); $this->addForeignKey('CUSTOMER_FAMILY_ID', 'CustomerFamilyId', 'INTEGER', 'customer_family', 'ID', true, null, null); + $this->addColumn('COMPANY_NAME', 'CompanyName', 'VARCHAR', false, 250, null); $this->addColumn('SIRET', 'Siret', 'VARCHAR', false, 50, null); $this->addColumn('VAT', 'Vat', 'VARCHAR', false, 50, null); } // initialize() @@ -296,11 +302,13 @@ public static function addSelectColumns(Criteria $criteria, $alias = null) if (null === $alias) { $criteria->addSelectColumn(CustomerCustomerFamilyTableMap::CUSTOMER_ID); $criteria->addSelectColumn(CustomerCustomerFamilyTableMap::CUSTOMER_FAMILY_ID); + $criteria->addSelectColumn(CustomerCustomerFamilyTableMap::COMPANY_NAME); $criteria->addSelectColumn(CustomerCustomerFamilyTableMap::SIRET); $criteria->addSelectColumn(CustomerCustomerFamilyTableMap::VAT); } else { $criteria->addSelectColumn($alias . '.CUSTOMER_ID'); $criteria->addSelectColumn($alias . '.CUSTOMER_FAMILY_ID'); + $criteria->addSelectColumn($alias . '.COMPANY_NAME'); $criteria->addSelectColumn($alias . '.SIRET'); $criteria->addSelectColumn($alias . '.VAT'); } diff --git a/templates/backOffice/default/customer-edit.html b/templates/backOffice/default/customer-edit.html index 20e9eb8..edd3ef0 100755 --- a/templates/backOffice/default/customer-edit.html +++ b/templates/backOffice/default/customer-edit.html @@ -36,10 +36,10 @@ {/form_field} {form_field form=$form field="company_name"} -
+
- + {if $error } {$message} {assign var="error_focus" value="true"}