Initial commit
This commit is contained in:
52
api-wiaas/server/components/v1/bids/BidMargin.php
Normal file
52
api-wiaas/server/components/v1/bids/BidMargin.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
class BidMargin{
|
||||
public function addBidMargin($idBid, $bidMargin){
|
||||
global $database;
|
||||
$data = [];
|
||||
$bidMargin = json_decode($bidMargin);
|
||||
|
||||
if($idBid === 0){
|
||||
$data['messages'][] =[
|
||||
'code' => 'error',
|
||||
'message' => 'BID_ID_REQUIRED'
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
if(!property_exists($bidMargin, 'fixedExtra')
|
||||
|| !property_exists($bidMargin, 'recurrentExtra')
|
||||
|| !property_exists($bidMargin, 'servicesExtra')){
|
||||
$data['messages'][] =[
|
||||
'code' => 'error',
|
||||
'message' => 'BID_MARGINS_REQUIRED'
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".TABLES['packages_bids']."
|
||||
SET fixedExtra=".$database->escapeValue($bidMargin->fixedExtra).",
|
||||
recurrentExtra=".$database->escapeValue($bidMargin->recurrentExtra).",
|
||||
servicesExtra=".$database->escapeValue($bidMargin->servicesExtra)."
|
||||
WHERE id=".$database->escapeValue($idBid);
|
||||
$query = $database->query($sql);
|
||||
|
||||
if($database->affectedRows() === 0){
|
||||
$data['messages'][] =[
|
||||
'code' => 'error',
|
||||
'message' => 'SERVER_ERROR'
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data['messages'][] = [
|
||||
'code' => 'success',
|
||||
'message' => 'BID_MARGIN_ADDED'
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
231
api-wiaas/server/components/v1/bids/Bids.php
Normal file
231
api-wiaas/server/components/v1/bids/Bids.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
class Bids {
|
||||
public function getBids($filter){
|
||||
global $database, $user;
|
||||
$data = [];
|
||||
$bids = [];
|
||||
$pricesHandler = new Prices();
|
||||
$interestRate = new InterestRate();
|
||||
$supplierBidsHandler = new SupplierBids();
|
||||
$interestRateValue = $interestRate->getInterestRate()['interestRate'];
|
||||
$interestRateCustomers = $interestRate->getInterestRateForCustomers();
|
||||
|
||||
$supplierBids = $supplierBidsHandler->getLinkedSupplierBids();
|
||||
$clSql = "";
|
||||
|
||||
if($user->getUserType() === USER_TYPES['COMMERCIAL_LEAD']){
|
||||
$clSql = " AND cl.idUser=".$user->getUserId();
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
pb.id AS idBid,
|
||||
pb.bidNumber,
|
||||
pb.idPackage,
|
||||
p.name AS packageName,
|
||||
pb.idCustomerInstance,
|
||||
pb.fixedExtra,
|
||||
pb.recurrentExtra,
|
||||
pb.servicesExtra,
|
||||
c.id AS idCustomer,
|
||||
c.name AS customer,
|
||||
cl.name AS commercialLead,
|
||||
pb.idPaymentType,
|
||||
pt.payType,
|
||||
pt.packagePayPeriod,
|
||||
pt.periodUnit,
|
||||
pb.startDate,
|
||||
pb.endDate,
|
||||
pb.fixedPrice,
|
||||
pb.principalAmount,
|
||||
pb.servicesPrice,
|
||||
CASE WHEN pb.endDate >= NOW() THEN 'available' ELSE 'expired' END AS status,
|
||||
CASE WHEN rop.idBid IS NULL THEN 0 ELSE 1 END AS isUsed
|
||||
FROM ".TABLES['packages_bids']." pb
|
||||
INNER JOIN ".TABLES['packages']." p
|
||||
ON p.id=pb.idPackage
|
||||
INNER JOIN ".TABLES['rel_commercial_lead_customers']." rclc
|
||||
ON rclc.id=pb.idCustomerInstance
|
||||
INNER JOIN ".TABLES['customers']." c
|
||||
ON c.id=rclc.idCustomer
|
||||
INNER JOIN ".TABLES['commercial_leads']." cl
|
||||
ON cl.id=rclc.idCommercialLead
|
||||
INNER JOIN ".TABLES['payment_types']." pt
|
||||
ON pt.id=pb.idPaymentType
|
||||
LEFT OUTER JOIN (
|
||||
SELECT DISTINCT idBid
|
||||
FROM ".TABLES['rel_order_packages']."
|
||||
) rop
|
||||
ON rop.idBid=pb.id
|
||||
WHERE 1=1 $clSql
|
||||
ORDER BY pb.bidNumber DESC";
|
||||
$query = $database->query($sql);
|
||||
while($row = $database->fetchArray($query)){
|
||||
$interestRateCust = $row['idCustomer'] && isset($interestRateCustomers[$row['idCustomer']]) ?
|
||||
floatval($interestRateCustomers[$row['idCustomer']]) :
|
||||
$interestRateValue;
|
||||
$row['recurrentPrice'] = $row['packagePayPeriod'] > 0
|
||||
? $pricesHandler->PMT($interestRateCust / 100, $row['packagePayPeriod'], $row['principalAmount'])
|
||||
: 0;
|
||||
$row['supplierBids'] = isset($supplierBids[$row['idBid']]) ? $supplierBids[$row['idBid']] : [];
|
||||
$row['status'] = intval($row['isUsed']) === 1 ? 'used' : $row['status'];
|
||||
$bids[] = $row;
|
||||
}
|
||||
$data['bids'] = $bids;
|
||||
$data['userType'] = $user->getUserType();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function validateBidData($bid){
|
||||
$messages = [];
|
||||
$requiredFields = ['idPackage', 'idCustomerInstance', 'idPaymentType', 'startDate', 'endDate', 'fixedPrice', 'principalAmount', 'servicesPrice'];
|
||||
|
||||
foreach ($requiredFields as $field) {
|
||||
if(!property_exists($bid , $field)){
|
||||
$messages[] = [
|
||||
'code' => 'error',
|
||||
'message' => $field.'_REQUIRED'
|
||||
];
|
||||
|
||||
return $messages;
|
||||
}
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
private function linkSupplierBids($idBid, $supplierBids){
|
||||
global $database;
|
||||
$data = [];
|
||||
|
||||
$sqlValues = "";
|
||||
foreach ($supplierBids as $supplierBid) {
|
||||
$sqlValues .= "($idBid, ".$supplierBid->idSupplierBid."),";
|
||||
}
|
||||
$sqlValues = rtrim($sqlValues, ',');
|
||||
|
||||
$sql = "INSERT INTO ".TABLES['rel_bid_supplier_bids']."
|
||||
(idBid, idSupplierBid)
|
||||
VALUES $sqlValues";
|
||||
$query = $database->query($sql);
|
||||
|
||||
if($database->affectedRows() < 1){
|
||||
$data['messages'][] =[
|
||||
'code' => 'error',
|
||||
'message' => 'SUPPLIER_BIDS_NOT_LINKED'
|
||||
];
|
||||
}else{
|
||||
$data['messages'][] = [
|
||||
'code' => 'success',
|
||||
'message' => 'SUPPLIER_BIDS_LINKED'
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function addBid($bid){
|
||||
global $database;
|
||||
|
||||
$bid = json_decode($bid);
|
||||
$checkData = $this->validateBidData($bid);
|
||||
|
||||
if(!empty($checkData)){
|
||||
$data['messages'] = $checkData;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
$sql = "SELECT MAX(id) as maxBidId FROM ".TABLES['packages_bids']." ";
|
||||
$maxVals = $database->fetchResultArray($sql);
|
||||
$maxId = !empty($maxVals) ? $maxVals[0]['maxBidId'] : 0;
|
||||
$bid->bidNumber = 10000001 + $maxId;
|
||||
|
||||
$sql = "INSERT INTO ".TABLES['packages_bids']."
|
||||
(bidNumber, idPackage, idCustomerInstance, idPaymentType, startDate, endDate, fixedPrice, principalAmount, servicesPrice)
|
||||
VALUES(
|
||||
'".$bid->bidNumber."',
|
||||
'".$bid->idPackage."',
|
||||
'".$bid->idCustomerInstance."',
|
||||
'".$bid->idPaymentType."',
|
||||
'".$bid->startDate."',
|
||||
'".$bid->endDate."',
|
||||
'".$bid->fixedPrice."',
|
||||
'".$bid->principalAmount."',
|
||||
'".$bid->servicesPrice."'
|
||||
)";
|
||||
|
||||
$query = $database->query($sql);
|
||||
|
||||
if($database->affectedRows() !== 1){
|
||||
$data['messages'][] =[
|
||||
'code' => 'error',
|
||||
'message' => 'SERVER_ERROR'
|
||||
];
|
||||
|
||||
return $data;
|
||||
}else{
|
||||
$data['messages'][] = [
|
||||
'code' => 'success',
|
||||
'message' => 'BID_ADDED'
|
||||
];
|
||||
}
|
||||
|
||||
$newBidId = $database->getInsertId();
|
||||
|
||||
if(property_exists($bid , 'supplierBids') && !empty($bid->supplierBids)){
|
||||
$insrtSupplierBidsMessage = $this->linkSupplierBids($newBidId, $bid->supplierBids);
|
||||
$data['messages'] = array_merge($data['messages'], $insrtSupplierBidsMessage['messages']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function removeBid($idBid){
|
||||
global $database;
|
||||
$data = [];
|
||||
|
||||
if(!$idBid){
|
||||
$data['messages'][] =[
|
||||
'code' => 'error',
|
||||
'message' => 'BID_REQUIRED'
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
$database->beginTransaction();
|
||||
$affectedRows = 0;
|
||||
$sql = "DELETE FROM ".TABLES['rel_bid_supplier_bids']."
|
||||
WHERE idBid=".$database->escapeValue($idBid);
|
||||
$query = $database->query($sql);
|
||||
$affectedRows = $database->affectedRows();
|
||||
|
||||
$sql = "DELETE FROM ".TABLES['packages_bids']."
|
||||
WHERE id=".$database->escapeValue($idBid);
|
||||
$query = $database->query($sql);
|
||||
$affectedRows += $database->affectedRows();
|
||||
|
||||
if($affectedRows < 1){
|
||||
$database->rollback();
|
||||
|
||||
$data['messages'][] =[
|
||||
'code' => 'error',
|
||||
'message' => 'SERVER_ERROR'
|
||||
];
|
||||
|
||||
return $data;
|
||||
}else{
|
||||
$database->commit();
|
||||
|
||||
$data['messages'][] = [
|
||||
'code' => 'success',
|
||||
'message' => 'BID_REMOVED'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
106
api-wiaas/server/components/v1/bids/BidsController.php
Normal file
106
api-wiaas/server/components/v1/bids/BidsController.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* BidssController controls the actions for bids
|
||||
*/
|
||||
class BidsController{
|
||||
private $model;
|
||||
|
||||
function __construct(){
|
||||
$this->model = new BidsModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* get bids for bids view
|
||||
* @return json list of bids
|
||||
*/
|
||||
public function getBids(){
|
||||
$filter = isset($_REQUEST['filter']) ? $_REQUEST['filter'] : '[]';
|
||||
echo json_encode($this->model->getBids($filter), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function removeBid(){
|
||||
$idBid = isset($_REQUEST['idBid']) ? $_REQUEST['idBid'] : 0;
|
||||
echo json_encode($this->model->removeBid($idBid), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function getClCustomers(){
|
||||
echo json_encode($this->model->getClCustomers(), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function getPayTypes(){
|
||||
$idCommercialLead = isset($_REQUEST['idCommercialLead']) ? $_REQUEST['idCommercialLead'] : 0;
|
||||
$idCustomer = isset($_REQUEST['idCustomer']) ? $_REQUEST['idCustomer'] : 0;
|
||||
$idPackage = isset($_REQUEST['idPackage']) ? $_REQUEST['idPackage'] : 0;
|
||||
echo json_encode($this->model->getPayTypes($idCommercialLead, $idCustomer, $idPackage), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function getPackages(){
|
||||
$idCommercialLead = isset($_REQUEST['idCommercialLead']) ? $_REQUEST['idCommercialLead'] : 0;
|
||||
$idCustomer = isset($_REQUEST['idCustomer']) ? $_REQUEST['idCustomer'] : 0;
|
||||
echo json_encode($this->model->getPackages($idCommercialLead, $idCustomer), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function getSuppliers(){
|
||||
echo json_encode($this->model->getSuppliers(), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function getProducts(){
|
||||
$idSupplier = isset($_REQUEST['idSupplier']) ? $_REQUEST['idSupplier'] : 0;
|
||||
|
||||
echo json_encode($this->model->getProducts($idSupplier), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function addSupplierBid(){
|
||||
$supplierBid = isset($_REQUEST['supplierBid']) ? $_REQUEST['supplierBid'] : '[]';
|
||||
|
||||
echo json_encode($this->model->addSupplierBid($supplierBid), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function getUnlinkedSupplierBids() {
|
||||
echo json_encode($this->model->getUnlinkedSupplierBids(), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function addBid(){
|
||||
$bid = isset($_REQUEST['bid']) ? $_REQUEST['bid'] : '[]';
|
||||
|
||||
echo json_encode($this->model->addBid($bid), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
public function addBidMargin() {
|
||||
$idBid = isset($_REQUEST['idBid']) ? $_REQUEST['idBid'] : 0;
|
||||
$bidMargin = isset($_REQUEST['bidMargin']) ? $_REQUEST['bidMargin'] : '[]';
|
||||
|
||||
echo json_encode($this->model->addBidMargin($idBid, $bidMargin), JSON_NUMERIC_CHECK);
|
||||
}
|
||||
|
||||
/**
|
||||
* include bids template
|
||||
*/
|
||||
public function bidsViewTemplate(){
|
||||
global $user;
|
||||
require_once('templates/BidsViewTemplate.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* include bids add template
|
||||
*/
|
||||
public function addBidTemplate(){
|
||||
require_once('templates/AddBidTemplate.php');
|
||||
}
|
||||
|
||||
public function addBidMarginTemplate(){
|
||||
require_once('templates/AddBidMarginTemplate.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* include bids template
|
||||
*/
|
||||
public function bidsTemplate(){
|
||||
global $user;
|
||||
require_once('templates/BidsTemplate.php');
|
||||
}
|
||||
|
||||
public function showPage(){
|
||||
require_once('BidsPage.php');
|
||||
}
|
||||
}
|
||||
70
api-wiaas/server/components/v1/bids/BidsModel.php
Normal file
70
api-wiaas/server/components/v1/bids/BidsModel.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
class BidsModel{
|
||||
public function getBids($filter){
|
||||
$bidsHandler = new Bids();
|
||||
|
||||
return $bidsHandler->getBids($filter);
|
||||
}
|
||||
|
||||
public function removeBid($idBid){
|
||||
$bidsHandler = new Bids();
|
||||
|
||||
return $bidsHandler->removeBid($idBid);
|
||||
}
|
||||
|
||||
public function getClCustomers(){
|
||||
$clCustomersHandler = new ClCustomers();
|
||||
|
||||
return $clCustomersHandler->getClAndCustomers();
|
||||
}
|
||||
|
||||
public function getPayTypes($idCommercialLead, $idCustomer, $idPackage){
|
||||
$packages = new Packages();
|
||||
$data['prices'] = $packages->getPricesForPackages($idCommercialLead, $idPackage, 1, 0, $idCustomer);
|
||||
$data['prices'] = isset($data['prices'][$idPackage]) ? $data['prices'][$idPackage] : [];
|
||||
|
||||
return $data['prices'];
|
||||
}
|
||||
|
||||
public function getPackages($idCommercialLead, $idCustomer){
|
||||
$customerPackagesHandler = new CustomerPackages();
|
||||
|
||||
return $customerPackagesHandler->getShopPackages($idCommercialLead, $idCustomer);
|
||||
}
|
||||
|
||||
public function getSuppliers(){
|
||||
$supplierBidsHandler = new SupplierBids;
|
||||
|
||||
return $supplierBidsHandler->getSuppliers();
|
||||
}
|
||||
|
||||
public function getProducts($idSupplier){
|
||||
$supplierBidsHandler = new SupplierBids;
|
||||
|
||||
return $supplierBidsHandler->getProducts($idSupplier);
|
||||
}
|
||||
|
||||
public function addSupplierBid($supplierBid){
|
||||
$supplierBidsHandler = new SupplierBids;
|
||||
|
||||
return $supplierBidsHandler->addSupplierBid($supplierBid);
|
||||
}
|
||||
|
||||
public function getUnlinkedSupplierBids(){
|
||||
$supplierBidsHandler = new SupplierBids;
|
||||
|
||||
return $supplierBidsHandler->getUnlinkedSupplierBids();
|
||||
}
|
||||
|
||||
public function addBid($bid){
|
||||
$bidsHandler = new Bids();
|
||||
|
||||
return $bidsHandler->addBid($bid);
|
||||
}
|
||||
|
||||
public function addBidMargin($idBid, $bidMargin){
|
||||
$bidMarginHandler = new BidMargin();
|
||||
|
||||
return $bidMarginHandler->addBidMargin($idBid, $bidMargin);
|
||||
}
|
||||
}
|
||||
12
api-wiaas/server/components/v1/bids/BidsPage.php
Normal file
12
api-wiaas/server/components/v1/bids/BidsPage.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<script src="<?php echo PATH_JS_COMPONENTS.'bids/bids.directive.js?v='.APPLICATION_VERSION;?>" type="text/javascript"></script>
|
||||
<script src="<?php echo PATH_JS_COMPONENTS.'bids/bids-view.directive.js?v='.APPLICATION_VERSION;?>" type="text/javascript"></script>
|
||||
<script src="<?php echo PATH_JS_COMPONENTS.'bids/add-bid.directive.js?v='.APPLICATION_VERSION;?>" type="text/javascript"></script>
|
||||
<script src="<?php echo PATH_JS_COMPONENTS.'bids/add-supplier-bid.controller.js?v='.APPLICATION_VERSION;?>" type="text/javascript"></script>
|
||||
<script src="<?php echo PATH_JS_COMPONENTS.'bids/link-supplier-bids.controller.js?v='.APPLICATION_VERSION;?>" type="text/javascript"></script>
|
||||
<script src="<?php echo PATH_JS_COMPONENTS.'bids/add-bid-margin.controller.js?v='.APPLICATION_VERSION;?>" type="text/javascript"></script>
|
||||
<script src="<?php echo PATH_JS_COMPONENTS.'bids/remove-bid.controller.js?v='.APPLICATION_VERSION;?>" type="text/javascript"></script>
|
||||
|
||||
<div id="bids-module" class="container-fluid col-md-12">
|
||||
<h1>{{ 'bids.TITLE' | translate }}</h1>
|
||||
<bids ng-controller="bidsCtrl"></bids>
|
||||
</div>
|
||||
161
api-wiaas/server/components/v1/bids/SupplierBids.php
Normal file
161
api-wiaas/server/components/v1/bids/SupplierBids.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
class SupplierBids{
|
||||
|
||||
public function getSuppliers(){
|
||||
global $database;
|
||||
|
||||
$sql = "SELECT
|
||||
s.id AS idSupplier,
|
||||
s.name AS supplier
|
||||
FROM ".TABLES['suppliers']." s
|
||||
ORDER BY s.name";
|
||||
|
||||
return $database->fetchResultArray($sql);
|
||||
}
|
||||
|
||||
private function validateBidData($bid){
|
||||
$messages = [];
|
||||
$requiredFields = ['idProduct', 'bidNumber'];
|
||||
|
||||
foreach ($requiredFields as $field) {
|
||||
if(!property_exists($bid , $field)){
|
||||
$messages[] = [
|
||||
'code' => 'error',
|
||||
'message' => $field.'_REQUIRED'
|
||||
];
|
||||
|
||||
return $messages;
|
||||
}
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function getProducts($idSupplier){
|
||||
global $database;
|
||||
|
||||
$sql = "SELECT
|
||||
p.idProduct,
|
||||
p.productName
|
||||
FROM ".TABLES['suppliers_countries_products']." p
|
||||
WHERE p.idSupplier=$idSupplier
|
||||
ORDER BY p.productName";
|
||||
|
||||
return $database->fetchResultArray($sql);
|
||||
}
|
||||
|
||||
public function addSupplierBid($supplierBid){
|
||||
global $database;
|
||||
|
||||
$supplierBid = json_decode($supplierBid);
|
||||
|
||||
$checkData = $this->validateBidData($supplierBid);
|
||||
|
||||
if(!empty($checkData)){
|
||||
$data['messages'] = $checkData;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".TABLES['supplier_bids']."
|
||||
(idProduct, bidNumber)
|
||||
VALUES(".$supplierBid->idProduct.", '".$supplierBid->bidNumber."')";
|
||||
|
||||
$query = $database->query($sql);
|
||||
|
||||
if($database->affectedRows() !== 1){
|
||||
$data['messages'][] =[
|
||||
'code' => 'error',
|
||||
'message' => 'SERVER_ERROR'
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
$data['messages'][] = [
|
||||
'code' => 'success',
|
||||
'message' => 'SUPPLIER_BID_ADDED'
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getUnlinkedSupplierBids(){
|
||||
global $database;
|
||||
$sql = "SELECT
|
||||
sb.id AS idSupplierBid,
|
||||
sb.bidNumber,
|
||||
sb.idProduct,
|
||||
p.productName,
|
||||
s.name AS supplier
|
||||
FROM ".TABLES['supplier_bids']." sb
|
||||
INNER JOIN ".TABLES['suppliers_countries_products']." p
|
||||
ON p.idProduct=sb.idProduct
|
||||
INNER JOIN ".TABLES['suppliers']." s
|
||||
ON s.id=p.idSupplier
|
||||
LEFT OUTER JOIN ".TABLES['rel_bid_supplier_bids']." rbsb
|
||||
ON rbsb.idSupplierBid=sb.id
|
||||
WHERE rbsb.idSupplierBid IS NULL";
|
||||
|
||||
return $database->fetchResultArray($sql);
|
||||
}
|
||||
|
||||
public function getLinkedSupplierBids(){
|
||||
global $database;
|
||||
$data = [];
|
||||
|
||||
$sql = "SELECT
|
||||
sb.id AS idSupplierBid,
|
||||
sb.bidNumber,
|
||||
sb.idProduct,
|
||||
p.productName,
|
||||
s.name AS supplier,
|
||||
rbsb.idBid
|
||||
FROM ".TABLES['supplier_bids']." sb
|
||||
INNER JOIN ".TABLES['suppliers_countries_products']." p
|
||||
ON p.idProduct=sb.idProduct
|
||||
INNER JOIN ".TABLES['suppliers']." s
|
||||
ON s.id=p.idSupplier
|
||||
INNER JOIN ".TABLES['rel_bid_supplier_bids']." rbsb
|
||||
ON rbsb.idSupplierBid=sb.id";
|
||||
$query = $database->query($sql);
|
||||
while($row = $database->fetchArray($query)){
|
||||
$data[$row['idBid']][] = $row;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getOrderSupplierBids($idOrder){
|
||||
global $database;
|
||||
$data = [];
|
||||
$idOrder = $database->escapeValue($idOrder);
|
||||
|
||||
$sql = "SELECT
|
||||
sb.id AS idSupplierBid,
|
||||
sb.bidNumber,
|
||||
sb.idProduct,
|
||||
p.productName,
|
||||
s.id AS idSupplier,
|
||||
s.name AS supplier,
|
||||
rbsb.idBid
|
||||
FROM ".TABLES['supplier_bids']." sb
|
||||
INNER JOIN ".TABLES['suppliers_countries_products']." p
|
||||
ON p.idProduct=sb.idProduct
|
||||
INNER JOIN ".TABLES['suppliers']." s
|
||||
ON s.id=p.idSupplier
|
||||
INNER JOIN ".TABLES['rel_bid_supplier_bids']." rbsb
|
||||
ON rbsb.idSupplierBid=sb.id
|
||||
INNER JOIN ".TABLES['rel_order_packages']." rop
|
||||
ON rbsb.idBid=rop.idBid
|
||||
WHERE rop.idOrder=$idOrder
|
||||
";
|
||||
$query = $database->query($sql);
|
||||
while($row = $database->fetchArray($query)){
|
||||
$data[$row['idSupplier']][] = $row;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<div id="add-bid-margin">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="bidNumber">{{ 'bids.labels.BID_NUMBER' | translate }}</label>
|
||||
<span>{{bid.bidNumber}}</span>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="fixedExtra">{{ 'bids.labels.fixedExtra' | translate }}</label>
|
||||
<input type="text" class="form-control"
|
||||
id="fixedExtra" placeholder="{{ 'bids.labels.fixedExtra' | translate }}"
|
||||
ng-model="bidMargin.fixedExtra">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="recurrentExtra">{{ 'bids.labels.recurrentExtra' | translate }}</label>
|
||||
<input type="text" class="form-control"
|
||||
id="recurrentExtra" placeholder="{{ 'bids.labels.recurrentExtra' | translate }}"
|
||||
ng-model="bidMargin.recurrentExtra">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="servicesExtra">{{ 'bids.labels.servicesExtra' | translate }}</label>
|
||||
<input type="text" class="form-control"
|
||||
id="servicesExtra" placeholder="{{ 'bids.labels.servicesExtra' | translate }}"
|
||||
ng-model="bidMargin.servicesExtra">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,90 @@
|
||||
<div id="add-bid" class="row">
|
||||
<form>
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="idCommercialLead">{{ 'bids.labels.COMEMRCIAL_LEADS' | translate }}</label>
|
||||
<select class="form-control"
|
||||
id="idCommercialLead" placeholder="{{ 'bids.labels.COMEMRCIAL_LEADS' | translate }}"
|
||||
ng-options="option.commercialLead for option in clCustomers track by option.idCommercialLead"
|
||||
ng-change="onCLSelect()"
|
||||
ng-model="selectedCl"></select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="idCustomerInstance">{{ 'bids.labels.CUSTOMER' | translate }}</label>
|
||||
<select class="form-control"
|
||||
id="idCustomerInstance" placeholder="{{ 'bids.labels.CUSTOMER' | translate }}"
|
||||
ng-options="option.customer for option in selectedCl.customers track by option.idCustomerInstance"
|
||||
ng-change="onCustomerSelect()"
|
||||
ng-model="selectedCustomer"></select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="idPackage">{{ 'bids.labels.PACKAGE' | translate }}</label>
|
||||
<select class="form-control"
|
||||
id="idPackage" placeholder="{{ 'bids.labels.PACKAGE' | translate }}"
|
||||
ng-options="option.packageName for option in packages track by option.idPackage"
|
||||
ng-change="onPackageSelect()"
|
||||
ng-model="selectedPackage"></select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="idPaymentType">{{ 'bids.labels.PAY_TYPE' | translate }}</label>
|
||||
<select class="form-control"
|
||||
id="idPaymentType" placeholder="{{ 'bids.labels.PAY_TYPE' | translate }}"
|
||||
ng-options="option.payType for option in payTypes track by option.idPaymentType"
|
||||
ng-change="onPayTypeSelect()"
|
||||
ng-model="selectedPayType"></select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="startDate">{{ 'bids.labels.START_DATE' | translate }}</label>
|
||||
<input type="text" class="form-control"
|
||||
id="startDate" placeholder="{{ 'bids.labels.START_DATE' | translate }}"
|
||||
datepicker
|
||||
ng-model="bid.startDate">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="endDate">{{ 'bids.labels.END_DATE' | translate }}</label>
|
||||
<input type="text" class="form-control"
|
||||
id="endDate" placeholder="{{ 'bids.labels.END_DATE' | translate }}"
|
||||
datepicker
|
||||
ng-model="bid.endDate">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="form-group">
|
||||
<label for="fixedPrice">{{ 'bids.labels.FIXED' | translate }}</label>
|
||||
<input type="text" class="form-control"
|
||||
id="fixedPrice" placeholder="{{ 'bids.labels.FIXED' | translate }}"
|
||||
ng-model="bid.fixedPrice">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="principalAmount">{{ 'bids.labels.PRINCIPAL_AMOUNT' | translate }}</label>
|
||||
<input type="text" class="form-control"
|
||||
id="principalAmount" placeholder="{{ 'bids.labels.PRINCIPAL_AMOUNT' | translate }}"
|
||||
ng-model="bid.principalAmount">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="servicesPrice">{{ 'bids.labels.SERVICES' | translate }}</label>
|
||||
<input type="text" class="form-control"
|
||||
id="servicesPrice" placeholder="{{ 'bids.labels.SERVICES' | translate }}"
|
||||
ng-model="bid.servicesPrice">
|
||||
</div>
|
||||
|
||||
<?php include('LinkedBidsTemplate.php'); ?>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<div ng-click="saveBid()" class="btn btn-primary">
|
||||
{{ 'bids.buttons.SAVE_BID' | translate }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,28 @@
|
||||
<div id="add-supplier-bid" ng-int="getSuppliers()">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="idSupplier">{{ 'bids.labels.SUPPLIER' | translate }}</label>
|
||||
<select class="form-control"
|
||||
id="idSupplier" placeholder="{{ 'bids.labels.SUPPLIER' | translate }}"
|
||||
ng-options="option.supplier for option in suppliers track by option.idSupplier"
|
||||
ng-change="onSupplierSelect()"
|
||||
ng-model="selectedSupplier"></select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="idProduct">{{ 'bids.labels.PRODUCT' | translate }}</label>
|
||||
<select class="form-control"
|
||||
id="idProduct" placeholder="{{ 'bids.labels.PRODUCT' | translate }}"
|
||||
ng-options="option.productName for option in products track by option.idProduct"
|
||||
ng-change="onProductSelect()"
|
||||
ng-model="selectedProduct"></select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="bidNumber">{{ 'bids.labels.BID_NUMBER' | translate }}</label>
|
||||
<input type="text" class="form-control"
|
||||
id="bidNumber" placeholder="{{ 'bids.labels.BID_NUMBER' | translate }}"
|
||||
ng-model="supplierBid.bidNumber">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div ng-if="bid.isUsed !== 1">
|
||||
<div ng-click="showBidMarginDialog(bid.idBid)" class="add-bid-margin-btn btn btn-primary">
|
||||
{{ 'bids.buttons.EDIT_MARGINS' | translate }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="isMarginsDialogVisible[bid.idBid]" ng-controller="addBidMarginCtrl">
|
||||
<div id="dialog-add-bid-margin-{{bid.idBid}}"
|
||||
dialog
|
||||
is-modal="true"
|
||||
has-buttons="true"
|
||||
on-confirmation="saveBidMargin"
|
||||
on-close="closeBidMarginDialog"
|
||||
parameters="{bid, getBids}"
|
||||
buttons-names="{confirmation: 'Add Margin', cancel: 'Cancel'}"
|
||||
title="{{'bids.headers.ADD_BID_MARGIN' | translate}}">
|
||||
<add-bid-margin ng-init="init(bid)"/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div ng-if="bid.isUsed !== 1">
|
||||
<div ng-click="showBidRemoveDialog(bid.idBid)" class="remove-bid-btn btn btn-danger">
|
||||
{{ 'bids.buttons.REMOVE' | translate }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="isRemoveDialogVisible[bid.idBid]" ng-controller="removeBidCtrl">
|
||||
<div id="dialog-remove-bid-{{bid.idBid}}"
|
||||
dialog
|
||||
is-modal="true"
|
||||
has-buttons="true"
|
||||
on-confirmation="removeBid"
|
||||
on-close="closeRemoveDialog"
|
||||
parameters="{bid, getBids}"
|
||||
buttons-names="{confirmation: 'Yes', cancel: 'Cancel'}"
|
||||
title="{{'bids.headers.REMOVE_BID' | translate}}">
|
||||
{{'bids.labels.REMOVE_BID_LABEL' | translate}} {{bid.bidNumber}}?
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if($user->getUserType() === USER_TYPES['BROKER']){
|
||||
include('BidsTemplateBroker.php');
|
||||
}
|
||||
|
||||
if($user->getUserType() === USER_TYPES['COMMERCIAL_LEAD']){
|
||||
include('BidsTemplateCommercialLead.php');
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<button type="button"
|
||||
id="bids-view-btn"
|
||||
subModule="bidsView"
|
||||
class="btn btn-default"
|
||||
ng-click="setSubModule($event)">{{ 'bids.buttons.VIEW_BIDS' | translate }}</button>
|
||||
|
||||
<button type="button"
|
||||
id="bids-add-btn"
|
||||
subModule="bidAdd"
|
||||
class="btn btn-default"
|
||||
ng-click="setSubModule($event)">{{ 'bids.buttons.ADD_BID' | translate }}</button>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12"
|
||||
id="bids-view-layer"
|
||||
ng-if="isSubmoduleVisible('bidsView')">
|
||||
<bids-view ng-controller="bidsViewCtrl" ng-init="getBids()"></bids-view>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12"
|
||||
id="bid-add-layer"
|
||||
ng-if="isSubmoduleVisible('bidAdd')">
|
||||
<add-bid ng-controller="addBidCtrl" ng-init="initAddBid()"></add-bid>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
<button type="button"
|
||||
id="bids-view-btn"
|
||||
subModule="bidsView"
|
||||
class="btn btn-default"
|
||||
ng-click="setSubModule($event)">{{ 'bids.buttons.VIEW_BIDS' | translate }}</button>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12"
|
||||
id="bids-view-layer"
|
||||
ng-if="isSubmoduleVisible('bidsView')">
|
||||
<bids-view ng-controller="bidsViewCtrl" ng-init="getBids()"></bids-view>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,110 @@
|
||||
<div id="bids-view">
|
||||
<div class="row bids-fitlers">
|
||||
<div class="col-lg-3">
|
||||
Search: <input ng-model="searchText" ng-change="filterBids('search')"/>
|
||||
</div>
|
||||
<div class="col-lg-5">
|
||||
Bid type:
|
||||
<select ng-change="filterBids(bidType)" ng-model="bidType">
|
||||
<option value='all'>All</option>
|
||||
<option value='available'>Available</option>
|
||||
<option value='used'>Used</option>
|
||||
<option value='expired'>Expired</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row bids-list">
|
||||
<div class="col-xl-4 col-lg-4 col-md-6 col-sm-12" ng-repeat="bid in filteredBids">
|
||||
<div class="bid-item {{bid.status}}">
|
||||
<div class="bid-number">
|
||||
<h4 class="col-lg-12">Bid: {{bid.bidNumber}} <span class="bid-date">( {{bid.startDate}} - {{bid.endDate}} )</span></h4>
|
||||
</div>
|
||||
<div class="bid-reference">
|
||||
<div class="{{HEADER_COL}}">
|
||||
Package:
|
||||
</div>
|
||||
<div class="{{LABEL_COL}}">
|
||||
{{bid.packageName}}
|
||||
</div>
|
||||
|
||||
<div class="{{HEADER_COL}}">
|
||||
Sold by:
|
||||
</div>
|
||||
<div class="{{LABEL_COL}}">
|
||||
{{bid.commercialLead}}
|
||||
</div>
|
||||
|
||||
<div class="{{HEADER_COL}}">
|
||||
Customer:
|
||||
</div>
|
||||
<div class="{{LABEL_COL}}">
|
||||
{{bid.customer}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="bid-pay-type">
|
||||
<div class="{{HEADER_COL}}">
|
||||
Pay Type:
|
||||
</div>
|
||||
<div class="{{LABEL_COL}}">
|
||||
{{bid.payType}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="bid-price">
|
||||
<div class="{{HEADER_COL}}">
|
||||
Fixed:
|
||||
</div>
|
||||
<div class="{{LABEL_COL}}">
|
||||
{{bid.fixedPrice}}
|
||||
<span ng-if="isCommercialLead">+ {{bid.fixedExtra}} = {{(bid.fixedPrice + bid.fixedExtra).toFixed(2)}}</span>
|
||||
</div>
|
||||
|
||||
<div class="{{HEADER_COL}}">
|
||||
Recurrent:
|
||||
</div>
|
||||
<div class="{{LABEL_COL}}">
|
||||
{{bid.recurrentPrice}}
|
||||
<span ng-if="isCommercialLead">+ {{bid.recurrentExtra}} = {{(bid.recurrentPrice + bid.recurrentExtra).toFixed(2)}}</span>
|
||||
</div>
|
||||
|
||||
<div class="{{HEADER_COL}}">
|
||||
Services:
|
||||
</div>
|
||||
<div class="{{LABEL_COL}}">
|
||||
{{bid.servicesPrice}}
|
||||
<span ng-if="isCommercialLead">+ {{bid.servicesExtra}} = {{(bid.servicesPrice + bid.servicesExtra).toFixed(2)}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bid-status">
|
||||
<div class="{{HEADER_COL}} {{bid.status}}-status">
|
||||
Status:
|
||||
</div>
|
||||
<div class="{{LABEL_COL}} {{bid.status}}-status">
|
||||
{{bid.status}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="supplier-bids">
|
||||
<div class="{{HEADER_COL}}">
|
||||
Supplier Bids:
|
||||
</div>
|
||||
<div class="{{LABEL_COL}}">
|
||||
<div ng-if="bid.supplierBids.length === 0">-</div>
|
||||
<div
|
||||
ng-repeat="supllierBid in bid.supplierBids">
|
||||
{{supllierBid.bidNumber}} {{supllierBid.supplier}} {{supllierBid.productName}},
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if($user->getUserType() === USER_TYPES['COMMERCIAL_LEAD']){
|
||||
include('BidsAddMarginButton.php');
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if($user->getUserType() === USER_TYPES['BROKER']){
|
||||
include('BidsRemoveButton.php');
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,22 @@
|
||||
<div id="link-supplier-bids" ng-init="getUnlinkedSupplierBids()">
|
||||
<div class="supplier-bids-list row">
|
||||
<div class="supplier-bid-header col-lg-12">
|
||||
<div class="col col-lg-4">{{ 'bids.labels.BID_NUMBER' | translate }}</diV>
|
||||
<div class="col col-lg-4">{{ 'bids.labels.SUPPLIER' | translate }}</diV>
|
||||
<div class="col col-lg-4">{{ 'bids.labels.PRODUCT' | translate }}</diV>
|
||||
</div>
|
||||
<div class="supplier-bid col-lg-12 {{supplierBid.class}}"
|
||||
ng-click="onSupBidSelect(supplierBid)"
|
||||
ng-repeat="supplierBid in supplierBids">
|
||||
<div class="col col-lg-4">
|
||||
{{supplierBid.bidNumber}}
|
||||
</div>
|
||||
<div class="col col-lg-4">
|
||||
{{supplierBid.supplier}}
|
||||
</div>
|
||||
<div class="col col-lg-4">
|
||||
{{supplierBid.productName}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,43 @@
|
||||
<div>
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<label>{{ 'bids.labels.SUPPLIER_BIDS' | translate }}</label>
|
||||
<span class="selected-supplier-bid" ng-repeat="supplierBid in bid.supplierBids">{{supplierBid.bidNumber}}, </span>
|
||||
</div>
|
||||
<div>
|
||||
<div ng-click="showLinkBidDialog()" class="btn btn-primary">
|
||||
{{ 'bids.buttons.LINK_BID' | translate }}
|
||||
</div>
|
||||
<div ng-click="showSupBidDialog()" class="btn btn-primary">
|
||||
{{ 'bids.buttons.ADD_BID' | translate }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="isLinkSupBidDialogVisible" ng-controller="linkSupplierBidsCtrl" ng-init="init(bid.supplierBids)">
|
||||
<div id="dialog-link-supplier-bid"
|
||||
dialog
|
||||
is-modal="true"
|
||||
has-buttons="true"
|
||||
on-confirmation="$parent.linkSuppliers"
|
||||
on-close="showLinkBidDialog"
|
||||
parameters="{selectedBids}"
|
||||
buttons-names="{confirmation: 'Link Supplier Bids', cancel: 'Cancel'}"
|
||||
title="{{'bids.headers.LINK_SUPPLIER_BIDS' | translate}}">
|
||||
<?php include('LinkSupplierBidsTemplate.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="isAddSupBidDialogVisible" ng-controller="addSupplierBidCtrl">
|
||||
<div id="dialog-add-supplier-bid"
|
||||
dialog
|
||||
is-modal="true"
|
||||
has-buttons="true"
|
||||
on-confirmation="saveSupplierBid"
|
||||
on-close="showSupBidDialog"
|
||||
buttons-names="{confirmation: 'Add Supplier Bid', cancel: 'Cancel'}"
|
||||
title="{{'bids.headers.SUPPLIER_BID' | translate}}">
|
||||
<?php include('AddSupplierBidTemplate.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user