list stocks
This commit is contained in:
parent
03c8d9b968
commit
a3b1753d9a
@ -19,7 +19,9 @@
|
|||||||
</h2>
|
</h2>
|
||||||
{{ activeSelling.length }} produit<span ng-if="activeSelling.length>1">s</span>
|
{{ activeSelling.length }} produit<span ng-if="activeSelling.length>1">s</span>
|
||||||
<input id="sellingComment" name="sellingComment" class="input input-lg" type="text" ng-model="sellingComment" placeholder="nom ou commentaire">
|
<input id="sellingComment" name="sellingComment" class="input input-lg" type="text" ng-model="sellingComment" placeholder="nom ou commentaire">
|
||||||
{{ sellingComment }}
|
<button class="btn btn-default" ng-click="clearSellingComment()">
|
||||||
|
<i class="fa fa-times"></i>
|
||||||
|
</button>
|
||||||
<hr>
|
<hr>
|
||||||
<ul>
|
<ul>
|
||||||
<li ng-repeat="p in activeSelling track by $index">
|
<li ng-repeat="p in activeSelling track by $index">
|
||||||
@ -28,7 +30,7 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" ng-model="p.name">
|
<input type="text" ng-model="p.name">
|
||||||
<span class="btn btn-warning input-group-addon remove-itm"
|
<span class="btn btn-warning input-group-addon remove-itm"
|
||||||
ng-click="activeSelling.splice($index,1); regenActiveSellingIds()">
|
ng-click="removeProduct(p,$index)">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,6 +21,9 @@ class="btn" ng-class="{'btn-success': expressSelling, 'btn-disabled':!expressSel
|
|||||||
<span class="badge">
|
<span class="badge">
|
||||||
{{ p.price }} €
|
{{ p.price }} €
|
||||||
</span>
|
</span>
|
||||||
|
<span class="badge badge-default">
|
||||||
|
{{ p.stockCount }}
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button ng-if="expressSelling" ng-click="expressSell(p)">
|
<button ng-if="expressSelling" ng-click="expressSell(p)">
|
||||||
<i class="fa fa-shopping-cart"></i>
|
<i class="fa fa-shopping-cart"></i>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Image</th>
|
<th>Image</th>
|
||||||
<th>Price</th>
|
<th>Price</th>
|
||||||
|
<th>Stocks</th>
|
||||||
<th>Comment</th>
|
<th>Comment</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -24,6 +25,7 @@
|
|||||||
<td>{{ product.name }}</td>
|
<td>{{ product.name }}</td>
|
||||||
<td>{{ product.image }}</td>
|
<td>{{ product.image }}</td>
|
||||||
<td>{{ product.price }}</td>
|
<td>{{ product.price }}</td>
|
||||||
|
<td>{{ product.stockCount }}</td>
|
||||||
<td>{{ product.comment }}</td>
|
<td>{{ product.comment }}</td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -10,7 +10,7 @@ angular
|
|||||||
$scope.recentSellings = [];
|
$scope.recentSellings = [];
|
||||||
$scope.lesParams = {};
|
$scope.lesParams = {};
|
||||||
$scope.paidAmount = 0;
|
$scope.paidAmount = 0;
|
||||||
$scope.expressSelling = false;
|
$scope.expressSelling = true;
|
||||||
$scope.pausedSelling = [];
|
$scope.pausedSelling = [];
|
||||||
$scope.activeItemsSold = []; // list of products ID to sell
|
$scope.activeItemsSold = []; // list of products ID to sell
|
||||||
$scope.activeSelling = []; // list of products to sell
|
$scope.activeSelling = []; // list of products to sell
|
||||||
@ -58,13 +58,26 @@ angular
|
|||||||
$scope.pauseSelling = function (selling) {
|
$scope.pauseSelling = function (selling) {
|
||||||
$scope.pausedSelling.push(selling);
|
$scope.pausedSelling.push(selling);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* add to current sell list
|
||||||
|
* @param product
|
||||||
|
*/
|
||||||
$scope.addProduct = function (product) {
|
$scope.addProduct = function (product) {
|
||||||
|
product.stockCount--;
|
||||||
$scope.activeSelling.push(product);
|
$scope.activeSelling.push(product);
|
||||||
$scope.activeItemsSold.push(product.id);
|
$scope.activeItemsSold.push(product.id);
|
||||||
$scope.regenActiveSellingIds();
|
$scope.regenActiveSellingIds();
|
||||||
document.querySelector('#sellingComment').focus()
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* remove from current sell list
|
||||||
|
* @param product
|
||||||
|
*/
|
||||||
|
$scope.removeProduct = function (product, index) {
|
||||||
|
product.stockCount++;
|
||||||
|
$scope.activeSelling.splice($index, 1);
|
||||||
|
$scope.regenActiveSellingIds()
|
||||||
|
};
|
||||||
$scope.pauseSelling = function () {
|
$scope.pauseSelling = function () {
|
||||||
$scope.pausedSelling.push(angular.copy($scope.activeSelling));
|
$scope.pausedSelling.push(angular.copy($scope.activeSelling));
|
||||||
$scope.activeSelling = [];
|
$scope.activeSelling = [];
|
||||||
@ -73,6 +86,11 @@ angular
|
|||||||
$scope.activeSelling = angular.copy(sellingList);
|
$scope.activeSelling = angular.copy(sellingList);
|
||||||
$scope.pausedSelling.splice(index, 1);
|
$scope.pausedSelling.splice(index, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.clearSellingComment = function () {
|
||||||
|
$scope.sellingComment = '';
|
||||||
|
document.querySelector('#sellingComment').focus();
|
||||||
|
}
|
||||||
$scope.clearCurrentSelling = function () {
|
$scope.clearCurrentSelling = function () {
|
||||||
$scope.paidAmount = 0;
|
$scope.paidAmount = 0;
|
||||||
$scope.sellingComment = "";
|
$scope.sellingComment = "";
|
||||||
|
@ -129,6 +129,7 @@ class DefaultController extends Controller {
|
|||||||
'name' => $product->getName(),
|
'name' => $product->getName(),
|
||||||
'category' => $category->getId(),
|
'category' => $category->getId(),
|
||||||
'price' => 1 * $product->getPrice(),
|
'price' => 1 * $product->getPrice(),
|
||||||
|
'stockCount' => $product->getStockCount(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$products = $listOfProductsInArray;
|
$products = $listOfProductsInArray;
|
||||||
@ -201,6 +202,9 @@ class DefaultController extends Controller {
|
|||||||
// link selling record with user, festival
|
// link selling record with user, festival
|
||||||
$currentUser->addProductsSold( $newProductSold );
|
$currentUser->addProductsSold( $newProductSold );
|
||||||
// persist all
|
// persist all
|
||||||
|
$productModel->setStockCount( $productModel->getStockCount() - 1 );
|
||||||
|
$m->persist( $productModel );
|
||||||
|
$m->persist( $newProductSold );
|
||||||
$m->persist( $newProductSold );
|
$m->persist( $newProductSold );
|
||||||
$sumAmount += $record[ 'price' ];
|
$sumAmount += $record[ 'price' ];
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class ProductCategoryController extends Controller {
|
|||||||
public function indexAction() {
|
public function indexAction() {
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$productCategories = $em->getRepository( 'AppBundle:ProductCategory' )->findAll();
|
$productCategories = $em->getRepository( 'AppBundle:ProductCategory' )->findByUser($this->getUser() );
|
||||||
|
|
||||||
return $this->render( 'productcategory/index.html.twig',
|
return $this->render( 'productcategory/index.html.twig',
|
||||||
[
|
[
|
||||||
|
@ -29,6 +29,7 @@ class Product {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* url for image
|
||||||
* @ORM\Column(type="string", length=256, nullable=true)
|
* @ORM\Column(type="string", length=256, nullable=true)
|
||||||
*/
|
*/
|
||||||
private $image;
|
private $image;
|
||||||
@ -150,8 +151,7 @@ class Product {
|
|||||||
*
|
*
|
||||||
* @return Product
|
* @return Product
|
||||||
*/
|
*/
|
||||||
public function setStockCount($stockCount)
|
public function setStockCount( $stockCount ) {
|
||||||
{
|
|
||||||
$this->stockCount = $stockCount;
|
$this->stockCount = $stockCount;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -162,8 +162,7 @@ class Product {
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getStockCount()
|
public function getStockCount() {
|
||||||
{
|
|
||||||
return $this->stockCount;
|
return $this->stockCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ class Product {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* url for image
|
||||||
* @ORM\Column(type="string", length=256, nullable=true)
|
* @ORM\Column(type="string", length=256, nullable=true)
|
||||||
*/
|
*/
|
||||||
private $image;
|
private $image;
|
||||||
@ -142,4 +143,26 @@ class Product {
|
|||||||
public function getUser() {
|
public function getUser() {
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set stockCount.
|
||||||
|
*
|
||||||
|
* @param int $stockCount
|
||||||
|
*
|
||||||
|
* @return Product
|
||||||
|
*/
|
||||||
|
public function setStockCount( $stockCount ) {
|
||||||
|
$this->stockCount = $stockCount;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get stockCount.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getStockCount() {
|
||||||
|
return $this->stockCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,15 @@ class ProductType extends AbstractType {
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
public function buildForm( FormBuilderInterface $builder, array $options ) {
|
||||||
$builder->add( 'name' )->add( 'image',
|
$builder->add( 'name' )
|
||||||
|
->add( 'image',
|
||||||
null,
|
null,
|
||||||
[ 'label' => 'URL pour image' ] )->add( 'price' )->add( 'comment' )->add( 'category' )->add( 'user' );
|
[ 'label' => 'URL pour image' ] )
|
||||||
|
->add( 'stockCount' )
|
||||||
|
->add( 'price' )
|
||||||
|
->add( 'comment' )
|
||||||
|
->add( 'category' )
|
||||||
|
->add( 'user' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user