Added fields to edit category, storelocations and manufacturer of a part.

This commit is contained in:
Jan Böhmer 2019-03-14 12:56:55 +01:00
parent 6f435a58c9
commit 86eda36a2e
5 changed files with 64 additions and 55 deletions

View file

@ -20,6 +20,7 @@ import 'datatables.net-bs4/css/dataTables.bootstrap4.css'
import 'datatables.net-buttons-bs4/css/buttons.bootstrap4.css' import 'datatables.net-buttons-bs4/css/buttons.bootstrap4.css'
import 'datatables.net-fixedheader-bs4/css/fixedHeader.bootstrap4.css' import 'datatables.net-fixedheader-bs4/css/fixedHeader.bootstrap4.css'
import 'datatables.net-select-bs4/css/select.bootstrap4.css' import 'datatables.net-select-bs4/css/select.bootstrap4.css'
import 'bootstrap-select/dist/css/bootstrap-select.css'
//require( 'jszip' ); //require( 'jszip' );
//#require( 'pdfmake' ); //#require( 'pdfmake' );
@ -31,6 +32,7 @@ require( 'datatables.net-buttons/js/buttons.print.js' );
//require( 'datatables.net-colreorder-bs4' )(); //require( 'datatables.net-colreorder-bs4' )();
require( 'datatables.net-fixedheader-bs4' ); require( 'datatables.net-fixedheader-bs4' );
require( 'datatables.net-select-bs4' ); require( 'datatables.net-select-bs4' );
require('bootstrap-select')
//Define jquery globally //Define jquery globally

View file

@ -18,6 +18,7 @@
}, },
"dependencies": { "dependencies": {
"@ckeditor/ckeditor5-build-classic": "^12.0.0", "@ckeditor/ckeditor5-build-classic": "^12.0.0",
"bootstrap-select": "1.13.5",
"datatables.net-bs4": "^1.10.19", "datatables.net-bs4": "^1.10.19",
"datatables.net-buttons-bs4": "^1.5.4", "datatables.net-buttons-bs4": "^1.5.4",
"datatables.net-fixedheader-bs4": "^3.1.5", "datatables.net-fixedheader-bs4": "^3.1.5",

View file

@ -322,24 +322,24 @@ class Part extends AttachmentContainingDBElement
/** /**
if ($with_devices) { if ($with_devices) {
$count_must_order = 0; // for devices with "order_only_missing_parts == false" $count_must_order = 0; // for devices with "order_only_missing_parts == false"
$count_should_order = 0; // for devices with "order_only_missing_parts == true" $count_should_order = 0; // for devices with "order_only_missing_parts == true"
$deviceparts = DevicePart::getOrderDeviceParts($this->database, $this->current_user, $this->log, $this->getID()); $deviceparts = DevicePart::getOrderDeviceParts($this->database, $this->current_user, $this->log, $this->getID());
foreach ($deviceparts as $devicepart) { foreach ($deviceparts as $devicepart) {
/** @var $devicepart DevicePart */ /** @var $devicepart DevicePart */
/** @var $device Device */ /** /** @var $device Device */ /**
$device = $devicepart->getDevice(); $device = $devicepart->getDevice();
if ($device->getOrderOnlyMissingParts()) { if ($device->getOrderOnlyMissingParts()) {
$count_should_order += $device->getOrderQuantity() * $devicepart->getMountQuantity(); $count_should_order += $device->getOrderQuantity() * $devicepart->getMountQuantity();
} else { } else {
$count_must_order += $device->getOrderQuantity() * $devicepart->getMountQuantity(); $count_must_order += $device->getOrderQuantity() * $devicepart->getMountQuantity();
} }
} }
return $count_must_order + max(0, $this->getMinInstock() - $this->getInstock() + $count_should_order); return $count_must_order + max(0, $this->getMinInstock() - $this->getInstock() + $count_should_order);
} else { } else {
return max(0, $this->getMinInstock() - $this->getInstock()); return max(0, $this->getMinInstock() - $this->getInstock());
} **/ } **/
} }
/** /**
@ -993,70 +993,61 @@ class Part extends AttachmentContainingDBElement
} }
/** /**
* Set the ID of the category * Set the category of this Part
* *
* Every part must have a valid category (in contrast to the * Every part must have a valid category (in contrast to the
* attributes "footprint", "storelocation", ...)! * attributes "footprint", "storelocation", ...)!
* *
* @param integer $new_category_id the ID of the category * @param Category $category The new category of this part
* *
* @return self * @return self
*/ */
public function setCategory(Category $category) : self public function setCategory(Category $category) : self
{ {
//TODO
$this->category = $category; $this->category = $category;
return $this; return $this;
} }
/** /**
* Set the footprint ID * Set the new Footprint of this Part.
* *
* @param integer|NULL $new_footprint_id * the ID of the footprint * @param Footprint|null $new_footprint The new footprint of this part. Set to null, if this part should not have
* * NULL means "no footprint" * a footprint.
* * @return self
* @throws Exception if the new footprint ID is not valid
* @throws Exception if there was an error
*/ */
public function setFootprintID($new_footprint_id) : self public function setFootprint(?Footprint $new_footprint) : self
{ {
//TODO $this->footprint = $new_footprint;
throw new \Exception("Not implemented yet!");
return $this;
}
/**
* Set the new store location of this part.
*
* @param Storelocation|null $new_storelocation The new Storelocation of this part. Set to null, if this part should
* not have a storelocation.
* @return Part
*/
public function setStorelocation(?Storelocation $new_storelocation) : self
{
$this->storelocation = $new_storelocation;
return $this; return $this;
} }
/** /**
* Set the storelocation ID * Sets the new manufacturer of this part.
* *
* @param integer|NULL $new_storelocation_id * the ID of the storelocation * @param Manufacturer|null $new_manufacturer The new Manufacturer of this part. Set to null, if this part should
* * NULL means "no storelocation" * not have a manufacturer.
* * @return Part
* @throws Exception if the new storelocation ID is not valid
* @throws Exception if there was an error
*/ */
public function setStorelocationID($new_storelocation_id) : self public function setManufacturer(?Manufacturer $new_manufacturer) : self
{ {
//TODO $this->manufacturer = $new_manufacturer;
throw new \Exception("Not implemented yet!");
return $this;
}
/**
* Set the manufacturer ID
*
* @param integer|NULL $new_manufacturer_id * the ID of the manufacturer
* * NULL means "no manufacturer"
*
* @throws Exception if the new manufacturer ID is not valid
* @throws Exception if there was an error
*/
public function setManufacturerID($new_manufacturer_id) : self
{
//TODO
throw new \Exception("Not implemented yet!");
return $this; return $this;
} }

View file

@ -32,8 +32,12 @@
namespace App\Form; namespace App\Form;
use App\Entity\Category;
use App\Entity\Manufacturer;
use App\Entity\Part; use App\Entity\Part;
use App\Entity\Storelocation;
use FOS\CKEditorBundle\Form\Type\CKEditorType; use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\UrlType; use Symfony\Component\Form\Extension\Core\Type\UrlType;
@ -57,6 +61,12 @@ class PartType extends AbstractType
['attr' => ['min'=>0, 'placeholder' => 'part.instock.placeholder'], 'label'=> 'instock.label']) ['attr' => ['min'=>0, 'placeholder' => 'part.instock.placeholder'], 'label'=> 'instock.label'])
->add('mininstock', IntegerType::class, ->add('mininstock', IntegerType::class,
['attr' => ['min'=>0, 'placeholder' => 'part.mininstock.placeholder'], 'label'=> 'mininstock.label']) ['attr' => ['min'=>0, 'placeholder' => 'part.mininstock.placeholder'], 'label'=> 'mininstock.label'])
->add('category', EntityType::class, ['class' => Category::class, 'choice_label' => 'full_path',
'attr' => ['class' => 'selectpicker', 'data-live-search' => true, 'label'=> 'category.label']])
->add('storelocation', EntityType::class, ['class' => Storelocation::class, 'choice_label' => 'full_path',
'attr' => ['class' => 'selectpicker', 'data-live-search' => true], 'required' => false, 'label'=> 'storelocation.label'])
->add('manufacturer', EntityType::class, ['class' => Manufacturer::class, 'choice_label' => 'full_path',
'attr' => ['class' => 'selectpicker', 'data-live-search' => true], 'required' => false, 'label'=> 'manufacturer.label'])
->add('manufacturer_product_url', UrlType::class, ['required'=>false, 'empty_data' => '', ->add('manufacturer_product_url', UrlType::class, ['required'=>false, 'empty_data' => '',
'label'=> 'manufacturer_url.label']) 'label'=> 'manufacturer_url.label'])
->add('comment', CKEditorType::class, ['required'=>false, ->add('comment', CKEditorType::class, ['required'=>false,

View file

@ -1186,6 +1186,11 @@ boolbase@^1.0.0, boolbase@~1.0.0:
resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24=
bootstrap-select@1.13.5:
version "1.13.5"
resolved "https://registry.yarnpkg.com/bootstrap-select/-/bootstrap-select-1.13.5.tgz#12f000b25a95ed642fe371ae9e311d3afbb8c53f"
integrity sha512-1uYsYLB4FvGdwM6qzIfTxp6sP5gDqjPgWNHJztBfYUTIo1GUYG5zzmMVWiJvdxJlsvBXZ9AObmeZdzi0eg2jaA==
bootstrap@^4.3.1: bootstrap@^4.3.1:
version "4.3.1" version "4.3.1"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.3.1.tgz#280ca8f610504d99d7b6b4bfc4b68cec601704ac" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.3.1.tgz#280ca8f610504d99d7b6b4bfc4b68cec601704ac"