Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<descriptive locale="fr_FR">
<title>Famille de clients et prix d'achat</title>
</descriptive>
<version>1.3.13</version>
<version>1.4.0</version>
<author>
<name>Guillaume Barral / Etienne Perriere</name>
<email>gbarral@openstudio.fr / eperriere@openstudio.fr</email>
Expand Down
1 change: 1 addition & 0 deletions Config/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<table name="customer_customer_family">
<column name="customer_id" primaryKey="true" required="true" type="INTEGER" />
<column name="customer_family_id" required="true" type="INTEGER" />
<column name="company_name" size="250" type="VARCHAR" />
<column name="siret" size="50" type="VARCHAR" />
<column name="vat" size="50" type="VARCHAR" />
<foreign-key foreignTable="customer" onDelete="CASCADE">
Expand Down
1 change: 1 addition & 0 deletions Config/thelia.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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`),
Expand Down
5 changes: 5 additions & 0 deletions Config/update/1.4.0.sql
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions Controller/Admin/CustomerFamilyAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
;
Expand Down
22 changes: 22 additions & 0 deletions Event/CustomerCustomerFamilyEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class CustomerCustomerFamilyEvent extends ActionEvent
/** @var int */
protected $customerFamilyId;

/** @var string */
protected $companyName;

/** @var string */
protected $siret;

Expand Down Expand Up @@ -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
*
Expand Down
1 change: 1 addition & 0 deletions EventListeners/CustomerFamilyListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public function customerCustomerFamilyUpdate(CustomerCustomerFamilyEvent $event)

$customerCustomerFamily
->setCustomerFamilyId($event->getCustomerFamilyId())
->setCompanyName($event->getCompanyName())
->setSiret($event->getSiret())
->setVat($event->getVat())
->save()
Expand Down
19 changes: 16 additions & 3 deletions Form/CustomerCustomerFamilyForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,23 @@ protected function buildForm()
'for' => 'customer_id'
)
))
->add('company_name','text', array(
'constraints' => array(
new Constraints\Callback(array("methods" => array(
array($this, "checkProfessionalInformation")
)))
),
'label' => Translator::getInstance()->trans(
'Company name',
array(),
CustomerFamily::MESSAGE_DOMAIN
),
'label_attr' => array(
'for' => 'company_name'
)
))
->add(
'siret',
'text',
array(
'siret','text', array(
'constraints' => array(
new Constraints\Callback(array("methods" => array(
array($this, "checkProfessionalInformation")
Expand Down
1 change: 1 addition & 0 deletions I18n/en_US.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
return array(
//C
"Customer family" => "Customer family",
"Company name" => "Company name",

//F
"Family of this customer" => "Customer family",
Expand Down
1 change: 1 addition & 0 deletions I18n/fr_FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions Loop/CustomerCustomerFamilyLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
;
Expand Down
70 changes: 64 additions & 6 deletions Model/Base/CustomerCustomerFamily.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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';
}
Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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]]);
}

/**
Expand All @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
28 changes: 18 additions & 10 deletions Model/Map/CustomerCustomerFamilyTableMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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, )
);

/**
Expand All @@ -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, )
);

Expand All @@ -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()
Expand Down Expand Up @@ -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');
}
Expand Down
14 changes: 14 additions & 0 deletions templates/backOffice/default/customer-edit.html
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -34,6 +35,19 @@
</div>
{/form_field}

{form_field form=$form field="company_name"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
<div class="control-input">
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="250" placeholder="{intl l="Placeholder Company name"}" value="{$_company_name_}" {if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
{if $error }
<span class="help-block">{$message}</span>
{assign var="error_focus" value="true"}
{/if}
</div>
</div>
{/form_field}

{form_field form=$form field="siret"}
<div class="form-group group-email {if $error}has-error{/if}">
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
Expand Down