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

View file

@ -9,11 +9,19 @@ class NameValue
return static::COLLECTION; 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 true;
return false; 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\InvoiceItem;
use App\Entity\User; use App\Entity\User;
use Doctrine\Common\Util\Debug;
class InvoiceCreator class InvoiceCreator
{ {
const VAT_RATE = 0.12; const VAT_RATE = 0.12;
@ -65,6 +67,13 @@ class InvoiceCreator
$total['vat_ex_price'] += $vat_ex_price; $total['vat_ex_price'] += $vat_ex_price;
$total['total_price'] += $sell_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 // get trade-ins
@ -76,6 +85,13 @@ class InvoiceCreator
$total['ti_rate'] += $ti_rate; $total['ti_rate'] += $ti_rate;
$total['total_price'] -= $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 // TODO: check if any promo is applied
@ -86,6 +102,10 @@ class InvoiceCreator
->setVAT($total['vat']) ->setVAT($total['vat'])
->setDiscount($total['ti_rate']); ->setDiscount($total['ti_rate']);
// dump
Debug::dump($invoice, 1);
return $invoice; return $invoice;
} }
} }

View file

@ -53,21 +53,7 @@
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane active" id="customer-info" role="tabpanel"> <div class="tab-pane active" id="customer-info" role="tabpanel">
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-4"> <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-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">
<label data-field="customer_classification"> <label data-field="customer_classification">
Customer Classification Customer Classification
</label> </label>
@ -77,10 +63,26 @@
{% endfor %} {% endfor %}
</select> </select>
<div class="form-control-feedback hide" data-field="customer_classification"></div> <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> </div>
<div class="form-group m-form__group row"> <div class="form-group m-form__group row">
<div class="col-lg-4"> <div class="col-lg-6">
<label data-field="customer_notes"> <label data-field="customer_notes">
Customer Notes Customer Notes
</label> </label>