initial commit'n push

This commit is contained in:
2019-06-11 11:49:27 +02:00
parent 3cc282f4a3
commit 98ecd72bea
44 changed files with 2880 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
chill_3party_controllers:
resource: "@ChillThirdPartyBundle/Controller"
type: annotation

View File

@@ -0,0 +1,7 @@
imports:
- { resource: './services/controller.yml' }
- { resource: './services/form.yml' }
- { resource: './services/security.yml' }
- { resource: './services/3partytype.yml' }
- { resource: './services/search.yml' }
- { resource: './services/menu.yml' }

View File

@@ -0,0 +1,2 @@
services:
Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager: ~

View File

@@ -0,0 +1,7 @@
services:
Chill\ThirdPartyBundle\Controller\ThirdPartyController:
arguments:
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$paginatorFactory: '@Chill\MainBundle\Pagination\PaginatorFactory'
tags: ['controller.service_arguments']

View File

@@ -0,0 +1,17 @@
services:
Chill\ThirdPartyBundle\Form\ThirdPartyType:
arguments:
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
$typesManager: '@Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager'
tags:
- { name: form.type }
Chill\ThirdPartyBundle\Form\Type\PickThirdPartyType:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
$urlGenerator: '@Symfony\Component\Routing\Generator\UrlGeneratorInterface'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$typesManager: '@Chill\ThirdPartyBundle\ThirdPartyType\ThirdPartyTypeManager'
tags:
- { name: form.type }

View File

@@ -0,0 +1,7 @@
services:
Chill\ThirdPartyBundle\Menu\MenuBuilder:
arguments:
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
tags:
- { name: 'chill.menu_builder' }

View File

@@ -0,0 +1,9 @@
services:
Chill\ThirdPartyBundle\Search\ThirdPartySearch:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$paginatorFactory: '@Chill\MainBundle\Pagination\PaginatorFactory'
tags:
- { name: 'chill.search', alias: '3party' }

View File

@@ -0,0 +1,7 @@
services:
Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter:
arguments:
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
tags:
- { name: security.voter }
- { name: chill.role }

View File

@@ -0,0 +1,35 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* add ThirdParty Entity
*
* @Author Mathieu Jaumotte jaum_mathieu@collectifs.net
*/
final class Version20190307111314 extends AbstractMigration
{
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE chill_third_party_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE chill_third_party (id INT NOT NULL, name VARCHAR(255) NOT NULL, telephone VARCHAR(64) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, comment TEXT DEFAULT NULL, type JSON DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN chill_third_party.type IS \'(DC2Type:json_array)\'');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP SEQUENCE chill_third_party_id_seq CASCADE');
$this->addSql('DROP TABLE chill_third_party');
}
}

View File

@@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Move table third-party to another schema
*/
final class Version20190307131650 extends AbstractMigration
{
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql("CREATE SCHEMA chill_3party");
$this->addSql("ALTER TABLE chill_third_party SET SCHEMA chill_3party");
$this->addSql("ALTER TABLE chill_3party.chill_third_party RENAME TO third_party");
$this->addSql("ALTER SEQUENCE chill_third_party_id_seq SET SCHEMA chill_3party");
$this->addSql("ALTER SEQUENCE chill_3party.chill_third_party_id_seq RENAME TO third_party_id_seq");
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->throwIrreversibleMigrationException("The down version of this migration is "
. "not written");
}
}

View File

@@ -0,0 +1,32 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add "centers" and "active" to 3rd party
*/
final class Version20190418090842 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE TABLE chill_3party.party_center (thirdparty_id INT NOT NULL, center_id INT NOT NULL, PRIMARY KEY(thirdparty_id, center_id))');
$this->addSql('CREATE INDEX IDX_C65D4397C7D3A8E6 ON chill_3party.party_center (thirdparty_id)');
$this->addSql('CREATE INDEX IDX_C65D43975932F377 ON chill_3party.party_center (center_id)');
$this->addSql('ALTER TABLE chill_3party.party_center ADD CONSTRAINT FK_C65D4397C7D3A8E6 FOREIGN KEY (thirdparty_id) REFERENCES chill_3party.third_party (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_3party.party_center ADD CONSTRAINT FK_C65D43975932F377 FOREIGN KEY (center_id) REFERENCES centers (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_3party.third_party ADD active BOOLEAN NOT NULL');
}
public function down(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP TABLE chill_3party.party_center');
$this->addSql('ALTER TABLE chill_3party.third_party DROP active');
}
}

View File

@@ -0,0 +1,26 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Alter third_party.type to jsonb and rename to types
*/
final class Version20190429171109 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$this->addSql("ALTER TABLE chill_3party.third_party RENAME COLUMN type "
. "TO types");
$this->addSql("ALTER TABLE chill_3party.third_party ALTER COLUMN types "
. "SET DATA TYPE jsonb");
}
public function down(Schema $schema) : void
{
$this->throwIrreversibleMigrationException("not implemented");
}
}

View File

@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add an address to parties
*/
final class Version20190502144206 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_3party.third_party ADD address_id INT DEFAULT NULL');
$this->addSql('COMMENT ON COLUMN chill_3party.third_party.types IS NULL');
$this->addSql('ALTER TABLE chill_3party.third_party ADD CONSTRAINT FK_D952467BF5B7AF75 FOREIGN KEY (address_id) REFERENCES chill_main_address (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_D952467BF5B7AF75 ON chill_3party.third_party (address_id)');
}
public function down(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_3party.third_party DROP CONSTRAINT FK_D952467BF5B7AF75');
$this->addSql('ALTER TABLE chill_3party.third_party DROP address_id');
}
}

View File

@@ -0,0 +1,3 @@
// sass/css
require('./sass/thirdparty.scss');

View File

@@ -0,0 +1,51 @@
div.chill_contact {
border: 1px solid black;
background-color: rgba(255, 255, 255, 0.65);
padding: 1em;
margin: 1em 0;
max-width: 500px;
div.chill_contact_name {
font-variant: small-caps;
}
div.chill_contact_category {
margin: 0.5em 0;
font-size: 85%;
span.category {
font-style: italic;
}
span::before {
margin-left: 0.5em;
margin-right: 0.5em;
font-family: 'FontAwesome';
content: '\f02e';
font-style: normal;
}
}
div.chill_contact_comment {
font-size: 85%;
font-style: italic;
}
div.chill_address {
div.chill_address_address::before {
margin-left: 0.5em;
margin-right: 0.5em;
font-family: 'FontAwesome';
content: '\f015';
}
}
div.chill_contact_contact {
font-variant: small-caps;
span::before {
margin-left: 0.5em;
margin-right: 0.5em;
font-family: 'FontAwesome';
}
span.email::before {
content: '\f1fa';
}
span.telephone::before {
content: '\f095';
}
}
}

View File

@@ -0,0 +1,26 @@
Third party: Tiers
Third parties: Tiers
name: Nom
telephone: Téléphone
adress: Adresse
email: Courriel
comment: Commentaire
thirdparty.type: type
thirdparty.Type: Type
thirdparty.No_phonenumber: Aucun numéro de téléphone
thirdparty.No_email: Aucun email
thirdparty.No_comment: Aucun commentaire
New third party: Nouveau tiers
Show third party %name%: Tiers "%name%"
Create third party: Créer un tiers
Update third party %name%: Mettre à jour "%name%"
List of third parties: Liste des tiers
Third party updated: Le tiers a été mis à jour
Third party created: Le tiers a été créé
Active, shown to users: Actif, visible par les utilisateurs
Inactive, not shown to users: Inactif, invisible par les utilisateurs
The party is visible in those centers: Le tiers est visible dans ces centres
No third parties: Aucun tiers

View File

@@ -0,0 +1,49 @@
{%- macro _render(contact, options) -%}
{%- set options = { 'with_valid_from' : true }|merge(options|default({})) -%}
<div class="chill_contact">
<div class="chill_contact_name">
{{ contact.name }}
</div>
<div class="chill_contact_category">
{% for type in contact.type %}
<span class="category">
{{ ('chill_3party.key_label.'~type)|trans }}
</span>
{% endfor %}
</div>
{% if contact.comment is not empty %}
<div class="chill_contact_comment">
{{ contact.comment }}
</div>
{% endif %}
{% if contact.address %}
<div class="chill_address">
<div class="chill_address_address">
{% if contact.address.streetAddress1 %}<p class="street street1">{{ contact.address.streetAddress1 }}</p>{% endif %}
{% if contact.address.streetAddress2 is not empty %}<p class="street street2">{{ contact.address.streetAddress2 }}</p>{% endif %}
{% if contact.address.postCode is not empty %}
<p class="postalCode"><span class="code">{{ contact.address.postCode.code }}</span> <span class="name">{{ contact.address.postCode.name }}</span></p>
<p class="country">{{ contact.address.postCode.country.name|localize_translatable_string }}</p>
{% endif %}
</div>
{%- if options['with_valid_from'] == true -%}
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : contact.address.validFrom|localizeddate('long', 'none') } ) }}</span>
{%- endif -%}
</div>
{% endif %}
{% if contact.email or contact.telephone is not empty %}
<div class="chill_contact_contact">
<span class="email">
{{ contact.email }}
</span>
<span class="telephone">
{{ contact.telephone }}
</span>
</div>
{% endif %}
</div>
{%- endmacro -%}

View File

@@ -0,0 +1,61 @@
{% extends "@ChillMain/layout.html.twig" %}
{% block title 'List of third parties'|trans %}
{% block content %}
<div class="grid-10 centered">
<h1>{{ 'List of third parties'|trans }}</h1>
{% if third_parties|length == 0 %}
<p class="chill-no-data-statement">{{ 'No third parties'|trans }}</p>
{% else %}
<table>
<thead>
<tr>
<th>{{ 'Name'|trans }}</th>
<th>{{ 'Active'|trans }}</th>
<th>{{ 'type'|trans }}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for tp in third_parties %}
<tr>
<td>{{ tp.name }}</td>
<td>{{ (tp.active ? '<i class="fa fa-check-square-o">' : '<i class="fa fa-square-o">')|raw }}</td>
{% set types = [] %}
{% for t in tp.type %}
{% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %}
{% endfor %}
<td>{{ types|join(', ') }}</td>
<td>
<ul class="record_actions">
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_3party_3party_update', { 'thirdparty_id': tp.id }) }}" class="sc-button bt-update"></a>
</li>
{% endif %}
{% if is_granted('CHILL_3PARTY_3PARTY_SHOW', tp) %}
<li>
<a href="{{ chill_path_add_return_path('chill_3party_3party_show', { 'thirdparty_id': tp.id }) }}" class="sc-button bt-show"></a>
</li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if is_granted('CHILL_3PARTY_3PARTY_CREATE') %}
<ul class="record_actions">
<li>
<a href="{{ chill_path_add_return_path('chill_3party_3party_new') }}" class="sc-button bt-create">
{{ "New third party"|trans }}
</a>
{% endif %}
</div>
{% endblock %}

View File

@@ -0,0 +1,34 @@
{% extends "@ChillMain/layout.html.twig" %}
{% block title 'Create third party'|trans %}
{% block content %}
<div class="grid-10 centered">
<h1>{{ 'Create third party'|trans }}</h1>
{{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.type) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.active) }}
{{ form_row(form.centers) }}
{{ form_row(form.comment) }}
<ul class="record_actions">
<li class="cancel">
<a href="{{ chill_return_path_or('chill_3party_3party_index') }}" class="sc-button bt-cancel">
{{ 'Back to the list'|trans }}
</a>
</li>
<li>
{{ form_widget(form.submit, {'label': 'Create', 'attr': {'class': 'sc-button bt-new' }}) }}
</li>
</ul>
{{ form_end(form) }}
</div>
{% endblock %}

View File

@@ -0,0 +1,67 @@
{% extends "@ChillMain/layout.html.twig" %}
{% import '@ChillMain/Address/macro.html.twig' as address %}
{% set title_ = 'Show third party %name%'|trans({'%name%' : thirdParty.name }) %}
{% block title title_ %}
{% block content %}
<div class="grid-10 centered">
<h1>
{{ title_ }}
<span class="chill__box {{ thirdParty.active ? 'green' : 'red' }}">{{ (thirdParty.active ? 'Active, shown to users' : 'Inactive, not shown to users')|trans }}</span>
</h1>
<dl class="chill_view_data">
<dt>{{ 'Name'|trans }}</dt>
<dd>{{ thirdParty.name }}</dd>
<dt>{{ 'Type'|trans }}</dt>
{% set types = [] %}
{% for t in thirdParty.type %}
{% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %}
{% endfor %}
<dd>{{ types|join(', ') }}</dd>
<dt>{{ 'Centers'|trans }}</dt>
<dd>{{ 'The party is visible in those centers'|trans }}&nbsp;: {{ thirdParty.centers|join(', ') }}</dd>
<dt>{{ 'Phonenumber'|trans }}</dt>
<dd>{{ thirdParty.telephone|chill_print_or_message("thirdparty.No_phonenumber") }}</dd>
<dt>{{ 'email'|trans }}<dt>
<dd>{{ thirdParty.email|chill_print_or_message("thirdparty.No_email") }}</dd>
<dt>{{ 'Address'|trans }}</dt>
<dd>
{% if thirdParty.address == null %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{% else %}
{{ address._render(thirdParty.address, {'with_valid_from': false }) }}
{% endif %}
</dd>
<dt>{{ 'Comment'|trans }}</dt>
<dd>{{ thirdParty.comment|chill_print_or_message("thirdparty.No_comment") }}</dd>
</dl>
<ul class="record_actions">
<li class="cancel">
<a class="sc-button bt-cancel" href="{{ chill_return_path_or('chill_3party_3party_index') }}">
{{ 'Cancel'|trans }}
</a>
</li>
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', thirdParty) %}
<li>
<a class="sc-button bt-update" href="{{ chill_path_forward_return_path('chill_3party_3party_update', { 'thirdparty_id': thirdParty.id }) }}">
{{ 'Update'|trans }}
</a>
</li>
{% endif %}
</ul>
</div>
{% endblock %}

View File

@@ -0,0 +1,37 @@
{% extends "@ChillMain/layout.html.twig" %}
{% block title 'Update third party %name%'|trans({ '%name%': thirdParty.name }) %}
{% block content %}
<div class="grid-10 centered">
<h1>
{{ 'Update third party %name%'|trans({ '%name%': thirdParty.name }) }}
<span class="chill__box {{ thirdParty.active ? 'green' : 'red' }}">{{ (thirdParty.active ? 'Active, shown to users' : 'Inactive, not shown to users')|trans }}</span>
</h1>
{{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.type) }}
{{ form_row(form.telephone) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.active) }}
{{ form_row(form.centers) }}
{{ form_row(form.comment) }}
<ul class="record_actions">
<li class="cancel">
<a class="sc-button bt-cancel" href="{{ chill_path_forward_return_path('chill_3party_3party_index') }}">
{{ 'Back to the list'|trans }}
</a>
<li>
{{ form_row(form.submit, {'label': 'Update', 'attr': {'class': 'sc-button bt-update' }}) }}
</li>
</ul>
{{ form_end(form) }}
</div>
{% endblock %}