Merge branch 'master' of gitlab.com:jankstudio/resq

This commit is contained in:
Ramon Gutierrez 2018-02-01 23:14:56 +08:00
commit 6c79281ff0
4 changed files with 74 additions and 39 deletions

View file

@ -101,7 +101,6 @@ class CustomerController extends BaseController
->getQuery()
->getResult();
$classifications = CustomerClassification::getCollection();
// process rows
$rows = [];
@ -110,7 +109,7 @@ class CustomerController extends BaseController
$row['id'] = $orow->getID();
$row['first_name'] = $orow->getFirstName();
$row['last_name'] = $orow->getLastName();
$row['customer_classification'] = $classifications[$orow->getCustomerClassification()];
$row['customer_classification'] = CustomerClassification::getName($orow->getCustomerClassification());
$row['flag_mobile_app'] = $orow->hasMobileApp();
$row['app_mobile_number'] = $orow->hasMobileApp() && !empty($orow->getMobileSessions()) ? $orow->getMobileSessions()[0]->getPhoneNumber() : '';
@ -410,16 +409,19 @@ class CustomerController extends BaseController
}
// delete all numbers not in list
$qb = $em->createQueryBuilder();
$del_numbers = $qb->select('m')
->from(MobileNumber::class, 'm')
->where($qb->expr()->notIn('m.id', $number_ids))
->getQuery()
->getResult();
if (count($number_ids) > 0)
{
$qb = $em->createQueryBuilder();
$del_numbers = $qb->select('m')
->from(MobileNumber::class, 'm')
->where($qb->expr()->notIn('m.id', $number_ids))
->getQuery()
->getResult();
if (!empty($del_numbers)) {
foreach ($del_numbers as $dn) {
$em->remove($dn);
if (!empty($del_numbers)) {
foreach ($del_numbers as $dn) {
$em->remove($dn);
}
}
}
@ -500,17 +502,20 @@ class CustomerController extends BaseController
}
}
// delete all vehicles not in list
$qb = $em->createQueryBuilder();
$del_vehicles = $qb->select('cv')
->from(CustomerVehicle::class, 'cv')
->where($qb->expr()->notIn('cv.id', $vehicle_ids))
->getQuery()
->getResult();
if (count($vehicle_ids) > 0)
{
// delete all vehicles not in list
$qb = $em->createQueryBuilder();
$del_vehicles = $qb->select('cv')
->from(CustomerVehicle::class, 'cv')
->where($qb->expr()->notIn('cv.id', $vehicle_ids))
->getQuery()
->getResult();
if (!empty($del_vehicles)) {
foreach ($del_vehicles as $dv) {
$em->remove($dv);
if (!empty($del_vehicles)) {
foreach ($del_vehicles as $dv) {
$em->remove($dv);
}
}
}

View file

@ -9,11 +9,19 @@ class NameValue
return static::COLLECTION;
}
static public function validate($type_text)
static public function validate($value)
{
if (isset(static::COLLECTION[$type_text]))
if (isset(static::COLLECTION[$value]))
return true;
return false;
}
static public function getName($value)
{
if (isset(static::COLLECTION[$value]))
return static::COLLECTION[$value];
return 'Unknown';
}
}

View file

@ -8,6 +8,8 @@ use App\Entity\Invoice;
use App\Entity\InvoiceItem;
use App\Entity\User;
use Doctrine\Common\Util\Debug;
class InvoiceCreator
{
const VAT_RATE = 0.12;
@ -65,6 +67,13 @@ class InvoiceCreator
$total['vat_ex_price'] += $vat_ex_price;
$total['total_price'] += $sell_price;
// add item
$item = new InvoiceItem();
$item->setInvoice($invoice)
->setTitle($batt->getModel() . ' ' . $batt->getSize())
->setQuantity(1)
->setPrice($sell_price);
}
// get trade-ins
@ -76,6 +85,13 @@ class InvoiceCreator
$total['ti_rate'] += $ti_rate;
$total['total_price'] -= $ti_rate;
// add item
$item = new InvoiceItem();
$item->setInvoice($invoice)
->setTitle('Trade-in battery')
->setQuantity(1)
->setPrice($ti_rate);
}
// TODO: check if any promo is applied
@ -86,6 +102,10 @@ class InvoiceCreator
->setVAT($total['vat'])
->setDiscount($total['ti_rate']);
// dump
Debug::dump($invoice, 1);
return $invoice;
}
}

View file

@ -53,21 +53,7 @@
<div class="tab-content">
<div class="tab-pane active" id="customer-info" role="tabpanel">
<div class="form-group m-form__group row">
<div class="col-lg-4">
<label data-field="first_name">
First Name
</label>
<input type="text" name="first_name" class="form-control m-input" value="{{ obj.getFirstName() }}" data-name="first_name">
<div class="form-control-feedback hide" data-field="first_name"></div>
</div>
<div class="col-lg-4">
<label data-field="last_name">
Last Name
</label>
<input type="text" name="last_name" class="form-control m-input" value="{{ obj.getLastName() }}" data-name="last_name">
<div class="form-control-feedback hide" data-field="last_name"></div>
</div>
<div class="col-lg-4">
<div class="col-lg-6">
<label data-field="customer_classification">
Customer Classification
</label>
@ -77,10 +63,26 @@
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="customer_classification"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-6">
<label data-field="first_name">
First Name
</label>
<input type="text" name="first_name" class="form-control m-input" value="{{ obj.getFirstName() }}" data-name="first_name">
<div class="form-control-feedback hide" data-field="first_name"></div>
</div>
<div class="col-lg-6">
<label data-field="last_name">
Last Name
</label>
<input type="text" name="last_name" class="form-control m-input" value="{{ obj.getLastName() }}" data-name="last_name">
<div class="form-control-feedback hide" data-field="last_name"></div>
</div>
</div>
<div class="form-group m-form__group row">
<div class="col-lg-4">
<div class="col-lg-6">
<label data-field="customer_notes">
Customer Notes
</label>