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