Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial setup, will probably still change a lot

  • Loading branch information...
commit 266f29389175bf67acdb0bd84bcb06e420e290db 1 parent 731bc72
@wjzijderveld wjzijderveld authored
View
28 DependencyInjection/VespolinaCustomerExtension.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * (c) Daniel Kucharski <daniel@xerias.be>
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle\DependencyInjection;
+
+use Symfony\Component\Config\Definition\Processor;
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\Config\FileLocator;
+
+class VespolinaPartnerExtension extends Extension
+{
+ public function load(array $configs, ContainerBuilder $container)
+ {
+ $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
+
+ foreach (array('mongodb') as $basename) {
+ $loader->load(sprintf('%s.xml', $basename));
+ }
+ }
+}
View
21 Document/BasePartner.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle\Document;
+
+use Vespolina\PartnerBundle\Model\Partner as AbstractPartner;
+
+abstract class BasePartner extends AbstractPartner
+{
+ protected $_id;
+
+ public function getId()
+ {
+ return $this->_id;
+ }
+}
View
14 Document/Partner.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle\Document;
+
+class Partner extends BasePartner
+{
+
+}
View
53 Document/PartnerManager.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+namespace Vespolina\PartnerBundle\Document;
+
+use Vespolina\PartnerBundle\Model\PartnerManager as BasePartnerManager;
+use Vespolina\PartnerBundle\Model\Partner as AbstractPartner;
+
+class PartnerManager extends BasePartnerManager
+{
+ /**
+ * Doctrine MongoDB DocumentManager
+ * @var \Doctrine\ODM\MongoDB\DocumentManager
+ */
+ protected $dm;
+
+ /**
+ * Dcotrine MongoDB DocumentRepository
+ *
+ * @var \Vespolina\PartnerBundle\Document\PartnerRepository
+ */
+ protected $repo;
+
+ /**
+ * @var BasePartner $partnerClass
+ */
+ protected $partnerClass;
+
+ public function __construct(Container $container, $partnerClass)
+ {
+ $this->dm = $container->get('doctrine.odm.mongodb.default_document_manager');
+ $this->partnerClass = $partnerClass;
+
+ $this->repo = $this->dm->getRepository('Partner');
+ }
+
+ public function createPartner($role = Partner::ROLE_CUSTOMER, $type = Partner::INDIVIDUAL)
+ {
+ /* @var $partner Partner */
+ $partner = new $this->partnerClass;
+ $partner->setRole($role);
+ $partner->setType($type);
+ }
+
+ public function findByPartnerId($partnerId)
+ {
+ return $this->repo->findOneBy(array('partnerId' => $partnerId));
+ }
+}
View
15 Document/PartnerRepository.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+namespace Vespolina\PartnerBundle\Document;
+
+use Doctrine\ODM\MongoDB\DocumentRepository;
+
+class PartnerRepository extends DocumentRepository
+{
+
+}
View
15 Model/OrganisationDetails.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+namespace Vespolina\PartnerBundle\Model;
+
+class OrganisationDetails
+{
+ protected $name;
+ protected $category;
+ protected $employees;
+}
View
306 Model/Partner.php
@@ -0,0 +1,306 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle\Model;
+
+use Doctrine\Common\Collections\ArrayCollection;
+
+/**
+ * Abstract implementation of Partner
+ *
+ * @author Willem-Jan Zijderveld <willemjan@beeldspraak.com>
+ */
+class Partner implements PartnerInterface
+{
+ const INDIVIDUAL = 'individual';
+ const ORGANISATION = 'organisation';
+
+ const ROLE_CUSTOMER = 'customer';
+ const ROLE_EMPLOYEE = 'employee';
+ const ROLE_SUPPLIER = 'supplier';
+
+ protected $partnerId;
+ protected $partnerSince;
+ protected $role;
+ protected $shortName;
+ protected $longName;
+ protected $type;
+ protected $valuta;

We should probably use currency here, although valuta looks much cooler :)

@wjzijderveld Owner

I didn't get a notification about your comment.. Just committed the change from valuta to currency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ protected $language;
+ protected $paymentTerms;
+ protected $paymentType;
+ protected $email;
+ protected $phone;
+ protected $addresses;
+ protected $contacts;
+ protected $personalDetails;
+ protected $organisationDetails;
+
+ public function __construct()
+ {
+ $this->addresses = new ArrayCollection();
+ $this->contacts = new ArrayCollection();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPartnerId()
+ {
+ return $this->partnerId;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setPartnerId($partnerId)
+ {
+ $this->partnerId = $partnerId;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPartnerSince()
+ {
+ return $this->partnerSince;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setPartnerSince(DateTime $partnerSince)
+ {
+ $this->partnerSince = $partnerSince;
+ }
+
+ /**
+ * @return string $role
+ */
+ public function getRole()
+ {
+ return $this->role;
+ }
+
+ /**
+ * @param string $role
+ */
+ public function setRole($role)
+ {
+ $this->role = $role;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getShortName()
+ {
+ return $this->shortName;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setShortName($shortName)
+ {
+ $this->shortName = $shortName;
+ }
+
+ /**
+ * @return the $longName
+ */
+ public function getLongName()
+ {
+ return $this->longName;
+ }
+
+ /**
+ * @param field_type $longName
+ */
+ public function setLongName($longName)
+ {
+ $this->longName = $longName;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getValuta()
+ {
+ return $this->valuta;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setValuta($valuta)
+ {
+ $this->valuta = $valuta;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getLanguage()
+ {
+ return $this->language;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setLanguage($language)
+ {
+ $this->language = $language;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPaymentTerms()
+ {
+ return $this->paymentTerms;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setPaymentTerms($paymentTerms)
+ {
+ $this->paymentTerms = $paymentTerms;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPhone()
+ {
+ return $this->phone;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setPhone($phone)
+ {
+ $this->phone = $phone;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getAddresses()
+ {
+ return $this->addresses;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setAddresses($addresses)
+ {
+ $this->addresses = $addresses;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function addAddress($address)
+ {
+ $this->addresses[] = $address;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getContacts()
+ {
+ return $this->contacts;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setContacts($contacts)
+ {
+ $this->contacts = $contacts;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function addContact($contact)
+ {
+ $this->contacts[] = $contact;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPersonalDetails()
+ {
+ return $this->personalDetails;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setPersonalDetails($personalDetails)
+ {
+ $this->personalDetails = $personalDetails;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getOrganisationDetails()
+ {
+ return $this->organisationDetails;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setOrganisationDetails($organisationDetails)
+ {
+ $this->organisationDetails = $organisationDetails;
+ }
+
+}
View
233 Model/PartnerInterface.php
@@ -0,0 +1,233 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle\Model;
+
+/**
+ * Partner interface, define basic fields
+ *
+ * @author Willem-Jan Zijderveld <willemjan@beeldspraak.com>
+ */
+interface PartnerInterface
+{
+ /**
+ * Sets the partnerId
+ *
+ * @param string $partnerId
+ */
+ function setPartnerId($partnerId);
+
+ /**
+ * Functional partner id
+ *
+ * @return string
+ */
+ function getPartnerId();
+
+ /**
+ * Date since when this partner joined
+ * @param DateTime $partnerSince
+ */
+ function setPartnerSince(DateTime $partnerSince);
+
+ /**
+ * @return DateTime
+ */
+ function getPartnerSince();
+
+ /**
+ * THe role of the Partner (e.g. Customer, Supplier, Employee)
+ * @return string
+ */
+ function getRole();
+
+ /**
+ * Sets the role of the partner
+ *
+ * @param string $role
+ */
+ function setRole($role);
+
+ /**
+ * Sets the partners shortname
+ *
+ * @param string $shortName
+ */
+ function setShortName($shortName);
+
+ /**
+ * Shortname of partner
+ *
+ * @return string
+ */
+ function getShortName();
+
+ /**
+ * Sets the long name
+ *
+ * @param string $longName
+ */
+ function setLongName($longName);
+
+ /**
+ * Long name for partner
+ *
+ * @return string
+ */
+ function getLongName();
+
+ /**
+ * Sets the partners phone number
+ *
+ * @param string $phone
+ */
+ function setPhone($phone);
+
+ /**
+ * Primary phone number
+ *
+ * @return string
+ */
+ function getPhone();
+
+ /**
+ * Sets the partners emailaddress
+ * @param string $email
+ */
+ function setEmail($email);
+
+ /**
+ * Primary email address for communication
+ *
+ * @return string
+ */
+ function getEmail();
+
+ /**
+ * Sets the partners default valuta (ISO-4217)
+ * @param string $valuta
+ */
+ function setValuta($valuta);
+
+ /**
+ * Default valuta for partner
+ *
+ * @return string - ISO-4217
+ */
+ function getValuta();
+
+ /**
+ * Sets the partners default language
+ *
+ * @param string $language - IETF tag
+ */
+ function setLanguage($language);
+
+ /**
+ * Default language for partner
+ *
+ * @return string - IETF tag
+ */
+ function getLanguage();
+
+ /**
+ * Sets the default payment terms for customer
+ *
+ * @param string $paymentTerms
+ */
+ function setPaymentTerms($paymentTerms);
+
+ /**
+ * Default payment terms for partner
+ */
+ function getPaymentTerms();
+
+ /**
+ * Sets the partners type
+ *
+ * @param string $type
+ */
+ function setType($type);
+
+ /**
+ * Discriminator field
+ *
+ * @return string
+ */
+ function getType();
+
+ /**
+ * Sets the partners addresses
+ *
+ * @param \Vespolina\CommonBundle\Model\Address[] $addresses
+ */
+ function setAddresses($addresses);
+
+ /**
+ * Adds a partners address
+ *
+ * @param \Vespolina\CommonBundle\Model\Address $address
+ */
+ function addAddress($address);
+
+ /**
+ * Addresses for this account
+ *
+ * @return \Vespolina\CommonBundle\Model\Address[]
+ */
+ function getAddresses();
+
+ /**
+ * Sets the partners contacts
+ *
+ * @param \Vespolina\CommonBundle\Model\Contact[] $contacts - Iterable contact collection
+ */
+ function setContacts($contacts);
+
+ /**
+ * Adds a partners Contact
+ *
+ * @param \Vespolina\CommonBundle\Model\Contact $contact
+ */
+ function addContact($contact);
+
+ /**
+ * Contacts for this accounts
+ *
+ * @return \Vespolina\CommonBundle\Model\Contact[]
+ */
+ function getContacts();
+
+ /**
+ * Sets the personal details for this partner
+ *
+ * @param $personalDetails
+ */
+ function setPersonalDetails($personalDetails);
+
+ /**
+ * Personal details of partner (used for type individual)
+ *
+ * @return mixed
+ */
+ function getPersonalDetails();
+
+ /**
+ * Sets the organistaion details
+ *
+ * @param $organisationDetails
+ */
+ function setOrganisationDetails($organisationDetails);
+
+ /**
+ * The organistaion details for this partner (used for type organisation)
+ *
+ * @return mixed
+ */
+ function getOrganisationDetails();
+}
View
19 Model/PartnerManager.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle\Model;
+
+/**
+ * PartnerManager - handles partner creation, updating, deletion, etc
+ *
+ * @author Willem-Jan Zijderveld <willemjan@beeldspraak.com>
+ */
+abstract class PartnerManager implements PartnerManagerInterface
+{
+
+}
View
24 Model/PartnerManagerInterface.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle\Model;
+
+interface PartnerManagerInterface
+{
+ /**
+ * Returns a new instance of given partner type
+ * @param string $partnerType
+ */
+ function createPartner($partnerType);
+
+ /**
+ * Returns a single partner with given partnerId
+ * @param string $partnerId
+ */
+ function findByPartnerId($partnerId);
+}
View
13 Model/PersonalDetails.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+namespace Vespolina\PartnerBundle\Model;
+
+class PersonalDetails
+{
+ protected $nationalIdentificationNumber; // shorter?
+}
View
16 Model/Role/Employee.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+namespace Vespolina\PartnerBundle\Model\Role;
+
+use Vespolina\PartnerBundle\Model\Partner as BasePartner;
+
+class Employee extends BasePartner
+{
+ protected $employeeId;
+ protected $accessLevel;
+}
View
14 Model/Role/Supplier.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+namespace Vespolina\PartnerBundle\Model\Role;
+
+use Vespolina\PartnerBundle\Model\Partner as BasePartner;
+
+class Supplier extends BasePartner
+{
+}
View
4 README.md
@@ -0,0 +1,4 @@
+VespolinaPartnerBundle
+======================
+
+The Vespolina PartnerBundle is meant to manage all actions done with your customers, clients, suppliers and so more.
View
17 Resources/config/mongodb.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<container xmlns="http://symfony.com/schema/dic/services"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
+
+ <parameters>
+ <parameter key="vespolina_partner.partner_manager.class">Vespolina\PartnerBundle\Document\PartnerManager</parameter>
+ <parameter key="vespolina_partner.model.partner.class">Vespolina\PartnerBundle\Document\Partner</parameter>
+ </parameters>
+
+ <services>
+ <service id="vespolina_partner.partner_manager" class="%vespolina_partner.partner_manager.class%">
+ <argument type="service" id="service_container" />
+ </service>
+ </services>
+</container>
View
25 Tests/Model/PartnerManagerTest.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle\Tests\Model;
+
+use Vespolina\PartnerBundle\Model\IndividualPartner;
+use Vespolina\PartnerBundle\Model\OrganisationPartner;
+use Vespolina\PartnerBundle\Model\Partner;
+use Vespolina\PartnerBundle\Tests\PartnerTestCommon;
+
+/**
+ * @author Willem-Jan Zijderveld <willemjan@beeldspraak.com>
+ */
+class PartnerManagerTest extends PartnerTestCommon
+{
+ protected function setUp()
+ {
+
+ }
+}
View
30 Tests/PartnerTestCommon.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * (c) Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle\Tests;
+
+use Vespolina\PartnerBundle\Model\IndividualPartner;
+
+use Vespolina\PartnerBundle\Model\PartnerManager;
+
+use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+
+abstract class PartnerTestCommon extends WebTestCase
+{
+ static $kernel;
+
+ public function getKernel(array $options = array())
+ {
+ if (!self::$kernel) {
+ self::$kernel = $this->createKernel($options);
+ self::$kernel->boot();
+ }
+
+ return self::$kernel;
+ }
+}
View
15 VespolinaPartnerBundle.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * (c) 2011 Vespolina Project http://www.vespolina-project.org
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+namespace Vespolina\PartnerBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class VespolinaPartnerBundle extends Bundle
+{
+}
View
25 composer.json
@@ -0,0 +1,25 @@
+{
+ "name": "vespolina/partner-bundle",
+ "type": "symfony-bundle",
+ "description": "Vespolina Partner Bundle, Customer (Relation) Management and more.",
+ "keywords": ["vespolina", "customer", "ecommerce", "partner", "crm"],
+ "homepage": "http://vespolina-project.org",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Vespolina Team",
+ "homepage": "https://github.com/vespolina/VespolinaPartnerBundle/contributors"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.2"
+ "symfony/doctrine-bundle": "*",
+ },
+ "suggests": {
+ "symfony/mongodb-odm-bundle": "*",
+ },
+ "autoload": {
+ "psr-0": { "Vespolina\\PartnerBundle": "" }
+ },
+ "target-dir": "Vespolina/PartnerBundle"
+}
Please sign in to comment.
Something went wrong with that request. Please try again.