@@ -87,6 +87,11 @@ class Distribution extends ActiveRecordCommon | |||
return $this->hasOne(Producer::class, ['id' => 'id_producer']); | |||
} | |||
public function populateProducer(Producer $producer): void | |||
{ | |||
$this->populateFieldObject('id_producer', 'producer', $producer); | |||
} | |||
public function getOrder() | |||
{ | |||
return $this->hasMany(Order::class, ['id_distribution' => 'id']); |
@@ -86,8 +86,18 @@ class PointSaleDistribution extends ActiveRecordCommon | |||
return $this->hasOne(Distribution::class, ['id' => 'id_distribution']); | |||
} | |||
public function populateDistribution(Distribution $distribution): void | |||
{ | |||
$this->populateFieldObject('id_distribution', 'distribution', $distribution); | |||
} | |||
public function getPointSale() | |||
{ | |||
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']); | |||
} | |||
public function populatePointSale(PointSale $pointSale): void | |||
{ | |||
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale); | |||
} | |||
} |
@@ -85,9 +85,19 @@ class ProductDistribution extends ActiveRecordCommon | |||
{ | |||
return $this->hasOne(Product::class, ['id' => 'id_product']); | |||
} | |||
public function populateProduct(Product $product): void | |||
{ | |||
$this->populateFieldObject('id_product', 'product', $product); | |||
} | |||
public function getDistribution() | |||
{ | |||
return $this->hasOne(Distribution::class, ['id' => 'id_distribution']); | |||
} | |||
public function populateDistribution(Distribution $distribution): void | |||
{ | |||
$this->populateFieldObject('id_distribution', 'distribution', $distribution); | |||
} | |||
} |
@@ -106,11 +106,21 @@ class Document extends ActiveRecordCommon implements DocumentInterface | |||
return $this->hasOne(User::class, ['id' => 'id_user']); | |||
} | |||
public function populateUser(User $user): void | |||
{ | |||
$this->populateFieldObject('id_user', 'user', $user); | |||
} | |||
public function getProducer() | |||
{ | |||
return $this->hasOne(Producer::class, ['id' => 'id_producer']); | |||
} | |||
public function populateProducer(Producer $producer): void | |||
{ | |||
$this->populateFieldObject('id_producer', 'producer', $producer); | |||
} | |||
public function relationOrders($fieldIdDocument) | |||
{ | |||
$orderRepository = new OrderRepository(); |
@@ -171,13 +171,17 @@ class Order extends ActiveRecordCommon | |||
$this->populateFieldObject('id_distribution', 'distribution', $distribution); | |||
} | |||
public function getPointSale() | |||
{ | |||
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']) | |||
->with('userPointSale'); | |||
} | |||
public function populatePointSale(PointSale $pointSale): void | |||
{ | |||
$this->populateFieldObject('id_point_sale', 'point_sale', $pointSale); | |||
} | |||
public function getCreditHistory() | |||
{ | |||
return $this->hasMany(CreditHistory::class, ['id_order' => 'id']); | |||
@@ -189,18 +193,38 @@ class Order extends ActiveRecordCommon | |||
->with('productSubscription'); | |||
} | |||
public function populateSubscription(Subscription $subscription): void | |||
{ | |||
$this->populateFieldObject('id_subscription', 'subscription', $subscription); | |||
} | |||
public function getInvoice() | |||
{ | |||
return $this->hasOne(Invoice::class, ['id' => 'id_invoice']); | |||
} | |||
public function populateInvoice(Invoice $invoice): void | |||
{ | |||
$this->populateFieldObject('id_invoice', 'invoice', $invoice); | |||
} | |||
public function getQuotation() | |||
{ | |||
return $this->hasOne(Quotation::class, ['id' => 'id_quotation']); | |||
} | |||
public function populateQuotation(Quotation $quotation): void | |||
{ | |||
$this->populateFieldObject('id_quotation', 'quotation', $quotation); | |||
} | |||
public function getDeliveryNote() | |||
{ | |||
return $this->hasOne(DeliveryNote::class, ['id' => 'id_delivery_note']); | |||
} | |||
public function populateDeliveryNote(DeliveryNote $deliveryNote): void | |||
{ | |||
$this->populateFieldObject('id_delivery_note', 'deliveryNote', $deliveryNote); | |||
} | |||
} |
@@ -55,8 +55,18 @@ class OrderStatusHistory extends ActiveRecordCommon | |||
return $this->hasOne(Order::class, ['id' => 'id_order']); | |||
} | |||
public function populateOrder(Order $order): void | |||
{ | |||
$this->populateFieldObject('id_order', 'order', $order); | |||
} | |||
public function getUser() | |||
{ | |||
return $this->hasOne(User::class, ['id' => 'id_user']); | |||
} | |||
public function populateUser(User $user): void | |||
{ | |||
$this->populateFieldObject('id_user', 'user', $user); | |||
} | |||
} |
@@ -69,7 +69,7 @@ class ProductOrder extends ActiveRecordCommon | |||
public function populateProduct(Product $product) | |||
{ | |||
$this->populateFieldObject('product', 'id_product', $product); | |||
$this->populateFieldObject('id_product', 'product', $product); | |||
} | |||
public function getOrder() | |||
@@ -79,7 +79,7 @@ class ProductOrder extends ActiveRecordCommon | |||
public function populateOrder(Order $order) | |||
{ | |||
$this->populateFieldObject('order', 'id_order', $order); | |||
$this->populateFieldObject('id_order', 'order', $order); | |||
} | |||
public function getTaxRate() | |||
@@ -89,7 +89,7 @@ class ProductOrder extends ActiveRecordCommon | |||
public function populateTaxRate(TaxRate $taxRate) | |||
{ | |||
$this->populateFieldObject('taxRate', 'id_tax_rate', $taxRate); | |||
$this->populateFieldObject('id_tax_rate', 'taxRate', $taxRate); | |||
} | |||
/** |
@@ -133,26 +133,22 @@ class PointSale extends ActiveRecordCommon | |||
public function getUserPointSale() | |||
{ | |||
return $this->hasMany( | |||
UserPointSale::class, | |||
['id_point_sale' => 'id'] | |||
); | |||
return $this->hasMany(UserPointSale::class, ['id_point_sale' => 'id']); | |||
} | |||
public function getPointSaleDistribution() | |||
{ | |||
return $this->hasMany( | |||
PointSaleDistribution::class, | |||
['id_point_sale' => 'id'] | |||
); | |||
return $this->hasMany(PointSaleDistribution::class, ['id_point_sale' => 'id']); | |||
} | |||
public function getUser() | |||
{ | |||
return $this->hasOne( | |||
User::class, | |||
['id' => 'id_user'] | |||
); | |||
return $this->hasOne(User::class, ['id' => 'id_user']); | |||
} | |||
public function populateUser(User $user): void | |||
{ | |||
$this->populateFieldObject('id_user', 'user', $user); | |||
} | |||
/** |
@@ -83,4 +83,9 @@ class UserPointSale extends ActiveRecordCommon | |||
{ | |||
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']); | |||
} | |||
public function populatePointSale(PointSale $pointSale): void | |||
{ | |||
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale); | |||
} | |||
} |
@@ -404,10 +404,7 @@ class Producer extends ActiveRecordCommon | |||
public function getUserProducer() | |||
{ | |||
return $this->hasMany( | |||
UserProducer::class, | |||
['id_producer' => 'id'] | |||
); | |||
return $this->hasMany(UserProducer::class, ['id_producer' => 'id']); | |||
} | |||
public function getUser() | |||
@@ -426,6 +423,11 @@ class Producer extends ActiveRecordCommon | |||
return $this->hasOne(TaxRate::class, ['id' => 'id_tax_rate_default']); | |||
} | |||
public function populateTaxRate(TaxRate $taxRate): void | |||
{ | |||
$this->populateFieldObject('id_tax_rate', 'taxRate', $taxRate); | |||
} | |||
// --- | |||
public static function getBillingTypePopulateDropdown() |
@@ -207,6 +207,11 @@ class Product extends ActiveRecordCommon | |||
return $this->hasOne(TaxRate::class, ['id' => 'id_tax_rate']); | |||
} | |||
public function populateTaxRate(TaxRate $taxRate): void | |||
{ | |||
$this->populateFieldObject('id_tax_rate', 'taxRate', $taxRate); | |||
} | |||
public function getProductPrice() | |||
{ | |||
return $this->hasMany( ProductPrice::class, ['id_product' => 'id']); | |||
@@ -217,6 +222,11 @@ class Product extends ActiveRecordCommon | |||
return $this->hasOne( ProductCategory::class, ['id' => 'id_product_category']); | |||
} | |||
public function populateProductCategory(ProductCategory $productCategory): void | |||
{ | |||
$this->populateFieldObject('id_product_category', 'productCategory', $productCategory); | |||
} | |||
public function getProductPointSale() | |||
{ | |||
return $this->hasMany(ProductPointSale::class, ['id_product' => 'id']); |
@@ -89,8 +89,18 @@ class ProductPointSale extends ActiveRecordCommon | |||
return $this->hasOne( Product::class, ['id' => 'id_product']); | |||
} | |||
public function populateProduct(Product $product): void | |||
{ | |||
$this->populateFieldObject('id_product', 'product', $product); | |||
} | |||
public function getPointSale() | |||
{ | |||
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']); | |||
} | |||
public function populatePointSale(PointSale $pointSale): void | |||
{ | |||
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale); | |||
} | |||
} |
@@ -130,18 +130,38 @@ class ProductPrice extends ActiveRecordCommon | |||
return $this->hasOne(Product::class, ['id' => 'id_product']); | |||
} | |||
public function populateProduct(Product $product): void | |||
{ | |||
$this->populateFieldObject('id_product', 'product', $product); | |||
} | |||
public function getPointSale() | |||
{ | |||
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']); | |||
} | |||
public function populatePointSale(PointSale $pointSale): void | |||
{ | |||
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale); | |||
} | |||
public function getUserGroup() | |||
{ | |||
return $this->hasOne(UserGroup::class, ['id' => 'id_user_group']); | |||
} | |||
public function populateUserGroup(UserGroup $userGroup): void | |||
{ | |||
$this->populateFieldObject('id_user_group', 'userGroup', $userGroup); | |||
} | |||
public function getUser() | |||
{ | |||
return $this->hasOne(User::class, ['id' => 'id_user']); | |||
} | |||
public function populateUser(User $user): void | |||
{ | |||
$this->populateFieldObject('id_user', 'user', $user); | |||
} | |||
} |
@@ -89,4 +89,9 @@ class ProductSubscription extends ActiveRecordCommon | |||
{ | |||
return $this->hasOne(Product::class, ['id' => 'id_product']); | |||
} | |||
public function populateProduct(Product $product): void | |||
{ | |||
$this->populateFieldObject('id_product', 'product', $product); | |||
} | |||
} |
@@ -112,16 +112,31 @@ class Subscription extends ActiveRecordCommon | |||
return $this->hasOne(User::class, ['id' => 'id_user']); | |||
} | |||
public function populateUser(User $user): void | |||
{ | |||
$this->populateFieldObject('id_user', 'user', $user); | |||
} | |||
public function getProducer() | |||
{ | |||
return $this->hasOne(Producer::class, ['id' => 'id_producer']); | |||
} | |||
public function populateProducer(Producer $producer): void | |||
{ | |||
$this->populateFieldObject('id_producer', 'producer', $producer); | |||
} | |||
public function getPointSale() | |||
{ | |||
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']); | |||
} | |||
public function populatePointSale(PointSale $pointSale): void | |||
{ | |||
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale); | |||
} | |||
public function getProductSubscription() | |||
{ | |||
return $this->hasMany(ProductSubscription::class, ['id_subscription' => 'id']) |
@@ -103,6 +103,11 @@ class CreditHistory extends ActiveRecordCommon | |||
return $this->hasOne(User::class, ['id' => 'id_user']); | |||
} | |||
public function populateUser(User $user): void | |||
{ | |||
$this->populateFieldObject('id_user', 'user', $user); | |||
} | |||
public function getUserObject(): ?User | |||
{ | |||
return $this->user; | |||
@@ -113,6 +118,11 @@ class CreditHistory extends ActiveRecordCommon | |||
return $this->hasOne(User::class, ['id' => 'id_user_action']); | |||
} | |||
public function populateUserAction(User $user): void | |||
{ | |||
$this->populateFieldObject('id_user_action', 'userAction', $user); | |||
} | |||
public function getUserActionObject(): ?User | |||
{ | |||
return $this->userAction; | |||
@@ -123,6 +133,11 @@ class CreditHistory extends ActiveRecordCommon | |||
return $this->hasOne(Order::class, ['id' => 'id_order']); | |||
} | |||
public function populateOrder(Order $order): void | |||
{ | |||
$this->populateFieldObject('id_order', 'order', $order); | |||
} | |||
public function getOrderObject(): ?Order | |||
{ | |||
return $this->order; |
@@ -89,24 +89,19 @@ class UserProducer extends ActiveRecordCommon | |||
return $this->hasOne(Producer::class, ['id' => 'id_producer']); | |||
} | |||
public function populateProducer(Producer $producer): void | |||
{ | |||
$this->populateFieldObject('id_producer', 'producer', $producer); | |||
} | |||
public function getUser() | |||
{ | |||
return $this->hasOne(User::class, ['id' => 'id_user']); | |||
} | |||
/** | |||
* Retourne les options de base nécessaires à la fonction de recherche. | |||
* | |||
* @return array | |||
*/ | |||
public static function defaultOptionsSearch() | |||
public function populateUser(User $user): void | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => 'user_producer.id_producer' | |||
]; | |||
$this->populateFieldObject('id_user', 'user', $user); | |||
} | |||
public function getIdUser(): int |
@@ -9,6 +9,16 @@ use common\logic\User\User\User; | |||
class UserProducerRepository extends BaseService implements RepositoryInterface | |||
{ | |||
public function defaultOptionsSearch(): array | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => [], | |||
'orderby' => '', | |||
'attribute_id_producer' => 'user_producer.id_producer' | |||
]; | |||
} | |||
public function getOne(User $user, Producer $producer) | |||
{ | |||
return UserProducer::searchOne([ |
@@ -82,4 +82,9 @@ class UserUserGroup extends ActiveRecordCommon | |||
{ | |||
return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']); | |||
} | |||
public function populatePointSale(PointSale $pointSale): void | |||
{ | |||
$this->populateFieldObject('id_point_sale', 'pointSale', $pointSale); | |||
} | |||
} |