finish add product to order , wip bon de commande pdf
This commit is contained in:
parent
0964e70c5f
commit
13768c442b
@ -163,8 +163,10 @@ return [
|
|||||||
['name' => 'order#createDefaultThanatoProductFee','url' => '/thanatoProductFees/createDefaultThanatoProductFee', 'verb' => 'POST'],
|
['name' => 'order#createDefaultThanatoProductFee','url' => '/thanatoProductFees/createDefaultThanatoProductFee', 'verb' => 'POST'],
|
||||||
['name' => 'order#orderDetails', 'url' => '/order/{orderId}/details', 'verb' => 'GET'],
|
['name' => 'order#orderDetails', 'url' => '/order/{orderId}/details', 'verb' => 'GET'],
|
||||||
['name' => 'order#getOrderProductsById', 'url' => '/order/{orderId}/products', 'verb' => 'PROPFIND'],
|
['name' => 'order#getOrderProductsById', 'url' => '/order/{orderId}/products', 'verb' => 'PROPFIND'],
|
||||||
|
['name' => 'order#getOrderItemsByOrderId', 'url' => '/order/{orderId}/items', 'verb' => 'PROPFIND'],
|
||||||
['name' => 'order#getOrderTotalAmount', 'url' => '/order/{orderId}/totalAmount', 'verb' => 'PROPFIND'],
|
['name' => 'order#getOrderTotalAmount', 'url' => '/order/{orderId}/totalAmount', 'verb' => 'PROPFIND'],
|
||||||
['name' => 'order#exportOrderToPdf', 'url' => '/order/{orderId}/exportToPdf', 'verb' => 'POST'],
|
['name' => 'order#exportOrderToPdf', 'url' => '/order/{orderId}/exportToPdf', 'verb' => 'POST'],
|
||||||
|
['name' => 'order#addOrderItems', 'url' => '/order/{orderId}/addItems', 'verb' => 'POST'],
|
||||||
|
|
||||||
//clients discount
|
//clients discount
|
||||||
['name' => 'page#getClientGroupDiscounts', 'url' => '/getClientGroupDiscounts', 'verb' => 'PROPFIND'],
|
['name' => 'page#getClientGroupDiscounts', 'url' => '/getClientGroupDiscounts', 'verb' => 'PROPFIND'],
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -198,8 +198,6 @@ class OrderController extends Controller {
|
|||||||
* @param string $orderId
|
* @param string $orderId
|
||||||
*/
|
*/
|
||||||
public function orderDetails($orderId) {
|
public function orderDetails($orderId) {
|
||||||
$this->logger->debug("logId");
|
|
||||||
$this->logger->debug("$orderId");
|
|
||||||
$orderWithDetail = $this->orderService->getOrderByIdWithDetails($orderId);
|
$orderWithDetail = $this->orderService->getOrderByIdWithDetails($orderId);
|
||||||
return new TemplateResponse(
|
return new TemplateResponse(
|
||||||
'gestion',
|
'gestion',
|
||||||
@ -220,8 +218,8 @@ class OrderController extends Controller {
|
|||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
* @param string $orderId
|
* @param string $orderId
|
||||||
*/
|
*/
|
||||||
public function getOrderProductsById($orderId) {
|
public function getOrderItemsByOrderId($orderId) {
|
||||||
$orderProducts = $this->orderService->getOrderProductsById($orderId);
|
$orderProducts = $this->orderService->getOrderItemsByOrderId($orderId);
|
||||||
return json_encode($orderProducts);
|
return json_encode($orderProducts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,15 +255,6 @@ class OrderController extends Controller {
|
|||||||
return new TemplateResponse('gestion', 'orderProduct', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink()));
|
return new TemplateResponse('gestion', 'orderProduct', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @NoAdminRequired
|
|
||||||
* @NoCSRFRequired
|
|
||||||
*/
|
|
||||||
public function getOrderProducts() {
|
|
||||||
$orderProducts = $this->orderService->getOrderProducts();
|
|
||||||
return $orderProducts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
@ -280,5 +269,28 @@ class OrderController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*/
|
||||||
|
public function addOrderItems($orderId) {
|
||||||
|
try{
|
||||||
|
$this->orderService->addDefaultOrderItem($orderId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception $e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*/
|
||||||
|
public function getOrderProducts() {
|
||||||
|
$orderProducts = $this->orderService->getOrderProducts();
|
||||||
|
return $orderProducts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,13 +42,13 @@ class Bdd {
|
|||||||
"fk_client_group_id","fk_produit_id","ht_amount","client_group_name",
|
"fk_client_group_id","fk_produit_id","ht_amount","client_group_name",
|
||||||
"provider_name","provider_last_name","provider_company_name","provider_siret_number","provider_phone","provider_email",
|
"provider_name","provider_last_name","provider_company_name","provider_siret_number","provider_phone","provider_email",
|
||||||
"provider_address","provider_city","fk_provider_id",
|
"provider_address","provider_city","fk_provider_id",
|
||||||
"label");
|
"label","fk_order_id","fk_order_item_id");
|
||||||
$this->whiteTable = array("client", "lieu", "trajet", "devis", "produit_devis", "facture", "produit",
|
$this->whiteTable = array("client", "lieu", "trajet", "devis", "produit_devis", "facture", "produit",
|
||||||
"configuration", "ligne_trajet", "thanato", "article", "defunt", "article_devis",
|
"configuration", "ligne_trajet", "thanato", "article", "defunt", "article_devis",
|
||||||
"bibliotheque", "bijou_defunt", "obs_defunt", "hypo_defunt",
|
"bibliotheque", "bijou_defunt", "obs_defunt", "hypo_defunt",
|
||||||
"orders","thanato_product_discount",
|
"orders","thanato_product_discount",
|
||||||
"client_group_discount","client_group","provider",
|
"client_group_discount","client_group","provider",
|
||||||
"order_product");
|
"order_product","order_item");
|
||||||
$this->tableprefix = '*PREFIX*' ."gestion_";
|
$this->tableprefix = '*PREFIX*' ."gestion_";
|
||||||
$this->pdo = $db;
|
$this->pdo = $db;
|
||||||
$this->l = $l;
|
$this->l = $l;
|
||||||
|
|||||||
@ -97,6 +97,15 @@ class OrderBdd {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getLastOrderProductId(){
|
||||||
|
$sql = "SELECT max(order_product.id) as MAX_ORDER_PRODUCT_ID FROM ".$this->orderTablePrefix."order_product as order_product;";
|
||||||
|
$result = $this->execSQLNoJsonReturn($sql,[]);
|
||||||
|
if(!empty($result)){
|
||||||
|
return $result[0]['MAX_ORDER_PRODUCT_ID'];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public function getOrderByCalendarUuid($calendarUuid){
|
public function getOrderByCalendarUuid($calendarUuid){
|
||||||
$sql = "SELECT * FROM ".$this->orderTablePrefix."orders as orders
|
$sql = "SELECT * FROM ".$this->orderTablePrefix."orders as orders
|
||||||
WHERE orders.fk_calendar_uuid = ? LIMIT 1";
|
WHERE orders.fk_calendar_uuid = ? LIMIT 1";
|
||||||
@ -189,10 +198,11 @@ class OrderBdd {
|
|||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
order_item.id as order_item_id,
|
order_item.id as order_item_id,
|
||||||
order_item.quantity as order_item_quantity,
|
order_item.quantity as order_item_quantity,
|
||||||
|
order_item.fk_order_id as fk_order_id,
|
||||||
order_product.id as order_product_id,
|
order_product.id as order_product_id,
|
||||||
order_product.reference as order_product_reference,
|
order_product.reference as order_product_reference,
|
||||||
order_product.description as order_product_description,
|
order_product.label as order_product_label,
|
||||||
order_product.prix_unitaire as order_product_ht_price
|
order_product.ht_amount as order_product_ht_amount
|
||||||
FROM ".$this->orderTablePrefix."order_item as order_item
|
FROM ".$this->orderTablePrefix."order_item as order_item
|
||||||
LEFT JOIN ".$this->orderTablePrefix."order_product as order_product on order_item.fk_order_item_id = order_product.id
|
LEFT JOIN ".$this->orderTablePrefix."order_product as order_product on order_item.fk_order_item_id = order_product.id
|
||||||
WHERE order_item.fk_order_id = ?;";
|
WHERE order_item.fk_order_id = ?;";
|
||||||
@ -376,11 +386,9 @@ class OrderBdd {
|
|||||||
orders.order_number,
|
orders.order_number,
|
||||||
orders.order_full_number,
|
orders.order_full_number,
|
||||||
orders.order_comment,
|
orders.order_comment,
|
||||||
orders.fk_defunt_id,
|
|
||||||
orders.fk_lieu_id,
|
|
||||||
orders.fk_client_id,
|
|
||||||
orders.fk_thanato_id,
|
|
||||||
orders.fk_order_status_key,
|
orders.fk_order_status_key,
|
||||||
|
orders.fk_order_type_key,
|
||||||
|
orders.fk_devis_id,
|
||||||
thanato.id as thanato_id,
|
thanato.id as thanato_id,
|
||||||
thanato.nom as thanato_nom,
|
thanato.nom as thanato_nom,
|
||||||
thanato.prenom as thanato_prenom,
|
thanato.prenom as thanato_prenom,
|
||||||
@ -398,14 +406,24 @@ class OrderBdd {
|
|||||||
lieu.id as lieu_id,
|
lieu.id as lieu_id,
|
||||||
lieu.adresse as lieu_adresse,
|
lieu.adresse as lieu_adresse,
|
||||||
lieu.nom as lieu_nom,
|
lieu.nom as lieu_nom,
|
||||||
order_status.status_label as order_status_label
|
order_status.status_label as order_status_label,
|
||||||
|
provider.provider_name,
|
||||||
|
provider.provider_last_name,
|
||||||
|
provider.provider_company_name,
|
||||||
|
provider.provider_siret_number,
|
||||||
|
provider.provider_phone,
|
||||||
|
provider.provider_email,
|
||||||
|
provider.provider_address,
|
||||||
|
provider.provider_city
|
||||||
FROM "
|
FROM "
|
||||||
.$this->orderTablePrefix."orders as orders
|
.$this->orderTablePrefix."orders as orders
|
||||||
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on orders.fk_thanato_id = thanato.id
|
LEFT JOIN ".$this->orderTablePrefix."devis as devis on orders.fk_devis_id = devis.id
|
||||||
LEFT JOIN ".$this->orderTablePrefix."client as client on orders.fk_client_id = client.id
|
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on devis.id_thanato = thanato.id
|
||||||
LEFT JOIN ".$this->orderTablePrefix."defunt as defunt on orders.fk_defunt_id = defunt.id
|
LEFT JOIN ".$this->orderTablePrefix."client as client on devis.id_client = client.id
|
||||||
LEFT JOIN ".$this->orderTablePrefix."lieu as lieu on orders.fk_lieu_id = lieu.id
|
LEFT JOIN ".$this->orderTablePrefix."defunt as defunt on devis.id_defunt = defunt.id
|
||||||
|
LEFT JOIN ".$this->orderTablePrefix."lieu as lieu on devis.id_lieu = lieu.id
|
||||||
LEFT JOIN ".$this->orderTablePrefix."order_status as order_status on orders.fk_order_status_key = order_status.status_key
|
LEFT JOIN ".$this->orderTablePrefix."order_status as order_status on orders.fk_order_status_key = order_status.status_key
|
||||||
|
LEFT JOIN ".$this->orderTablePrefix."provider as provider on orders.fk_provider_id = provider.id
|
||||||
WHERE orders.id = ?
|
WHERE orders.id = ?
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
"
|
"
|
||||||
@ -423,10 +441,10 @@ class OrderBdd {
|
|||||||
$totalHt = 0;
|
$totalHt = 0;
|
||||||
$totalTtc = 0;
|
$totalTtc = 0;
|
||||||
$totalTvaAmount = 0;
|
$totalTvaAmount = 0;
|
||||||
$orderProducts = $this->getOrderProductsByOrderId($orderId);
|
$orderItems = $this->getOrderItemsByOrderId($orderId);
|
||||||
foreach($orderProducts as $orderProduct){
|
foreach($orderItems as $orderItem){
|
||||||
$totalHt += $orderProduct["produit_ht_price"] * $orderProduct["order_product_quantity"];
|
$totalHt += $orderItem["order_product_ht_amount"] * $orderItem["order_item_quantity"];
|
||||||
$totalTvaAmount += $orderProduct["produit_ht_price"] * $tva / 100;
|
$totalTvaAmount += $orderItem["order_product_ht_amount"] * $tva / 100;
|
||||||
$totalTtc += ($totalHt * ($tva + 100)) / 100;
|
$totalTtc += ($totalHt * ($tva + 100)) / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,4 +505,17 @@ class OrderBdd {
|
|||||||
}
|
}
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function addOrderItem($orderId,$orderProductId,$quantity){
|
||||||
|
$sql = "INSERT INTO `".$this->orderTablePrefix."order_item` (`fk_order_id`,`fk_order_item_id`,`quantity`) VALUES (?,?,?);";
|
||||||
|
$this->execSQLNoData($sql, array($orderId,$orderProductId,$quantity));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addDefaultOrderItem($orderId){
|
||||||
|
$lastOrderProductId = $this->getLastOrderProductId();
|
||||||
|
$defaultQuantity = 1;
|
||||||
|
$this->addOrderItem($orderId,$lastOrderProductId,$defaultQuantity);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -107,6 +107,10 @@ class OrderService {
|
|||||||
return $this->orderBdd->getOrderProductsByOrderId($orderId);
|
return $this->orderBdd->getOrderProductsByOrderId($orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOrderItemsByOrderId($orderId){
|
||||||
|
return $this->orderBdd->getOrderItemsByOrderId($orderId);
|
||||||
|
}
|
||||||
|
|
||||||
public function getOrderTotalAmount($orderId,$tva){
|
public function getOrderTotalAmount($orderId,$tva){
|
||||||
return $this->orderBdd->getOrderTotalAmount($orderId,$tva);
|
return $this->orderBdd->getOrderTotalAmount($orderId,$tva);
|
||||||
}
|
}
|
||||||
@ -135,4 +139,8 @@ class OrderService {
|
|||||||
public function createDefaultOrderProduct($idNextCloud){
|
public function createDefaultOrderProduct($idNextCloud){
|
||||||
$this->orderBdd->createDefaultOrderProduct($idNextCloud);
|
$this->orderBdd->createDefaultOrderProduct($idNextCloud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addDefaultOrderItem($orderId){
|
||||||
|
$this->orderBdd->addDefaultOrderItem($orderId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
import DataTable from "datatables.net";
|
import DataTable from "datatables.net";
|
||||||
import { Order } from "../objects/order.mjs";
|
import { Order } from "../objects/order.mjs";
|
||||||
import { updateOrderDate } from "../modules/order/orderAjaxRequest.mjs";
|
import { getOrderItemsByOrderId, loadOrderProductIntoSelect, updateOrderDate } from "../modules/order/orderAjaxRequest.mjs";
|
||||||
import { Thanatopracteur } from "../objects/thanatopracteur.mjs";
|
import { Thanatopracteur } from "../objects/thanatopracteur.mjs";
|
||||||
import { ThanatoSubcontractorTypeKey } from "../constants/thanatoTypeConstant";
|
import { ThanatoSubcontractorTypeKey } from "../constants/thanatoTypeConstant";
|
||||||
import { hideLoader, showLoader,baseUrl } from "../modules/mainFunction.mjs";
|
import { hideLoader, showLoader,baseUrl } from "../modules/mainFunction.mjs";
|
||||||
import { showError, showSuccess } from "@nextcloud/dialogs";
|
import { showError, showSuccess } from "@nextcloud/dialogs";
|
||||||
import { OrderProduct } from "../objects/orderProduct.mjs";
|
import { OrderProduct } from "../objects/orderProduct.mjs";
|
||||||
|
import { updateDB } from "../modules/ajaxRequest.mjs";
|
||||||
|
|
||||||
$('body').on('change', '.orderInputDate', function () {
|
$('body').on('change', '.orderInputDate', function () {
|
||||||
var dt = new DataTable('.tabledt');
|
var dt = new DataTable('.tabledt');
|
||||||
@ -56,3 +57,41 @@ $('body').on('click', '#exportOrderToPdf', function () {
|
|||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('body').on('click', '#addOrderItems', function () {
|
||||||
|
var orderId = $('#orderId').data('id');
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl + '/order/'+orderId+'/addItems',
|
||||||
|
type: 'POST',
|
||||||
|
contentType: 'application/json'
|
||||||
|
}).done(function (response) {
|
||||||
|
getOrderItemsByOrderId(orderId);
|
||||||
|
}).fail(function (response, code) {
|
||||||
|
showError(t('gestion', "Please create a new product"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('body').on('dblclick', '.selectableOrderItem', function () {
|
||||||
|
var orderItemId = $(this).data('order-item-id');
|
||||||
|
var orderProductId = $(this).data('data-order-product-id');
|
||||||
|
var orderId = $(this).data('order-id');
|
||||||
|
$(this).text("");
|
||||||
|
$(this).html('<select id="orderProductList">');
|
||||||
|
loadOrderProductIntoSelect($('#orderProductList'), orderItemId, orderProductId,orderId);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('body').on('change', '#orderProductList', function () {
|
||||||
|
var orderItemId = $(this).find(':selected').data('id')
|
||||||
|
var orderId = $(this).find(':selected').data('order-id')
|
||||||
|
var orderProductId = $(this).find(':selected').data('val')
|
||||||
|
var column = $(this).find(':selected').data('column')
|
||||||
|
var table = $(this).find(':selected').data('table')
|
||||||
|
var el = $(this).parent();
|
||||||
|
|
||||||
|
updateDB(table, column, orderProductId, orderItemId);
|
||||||
|
getOrderItemsByOrderId(orderId);
|
||||||
|
|
||||||
|
el.text($(this).val());
|
||||||
|
el.attr('data-val', orderProductId);
|
||||||
|
|
||||||
|
});
|
||||||
@ -825,3 +825,39 @@ export function exportCareCertificate(defuntIdPayload) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a product in database using devisId
|
||||||
|
*/
|
||||||
|
export function getProduitsByDevisId(devisId) {
|
||||||
|
var myData = { numdevis: devisId };
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl + '/getProduitsById',
|
||||||
|
type: 'POST',
|
||||||
|
async: false,
|
||||||
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify(myData)
|
||||||
|
}).done(function (response, code) {
|
||||||
|
$('#produits tbody').empty();
|
||||||
|
var total = 0;
|
||||||
|
var deleteDisable = "";
|
||||||
|
if ($('#produits').data("type") === "facture") {
|
||||||
|
deleteDisable = "d-none";
|
||||||
|
}
|
||||||
|
|
||||||
|
$.each(JSON.parse(response), function (arrayID, myresp) {
|
||||||
|
$('#produits tbody').append('<tr><td><div data-modifier="getProduitsById" data-id="' + myresp.pdid + '" data-table="produit_devis" class="' + deleteDisable + ' deleteItem icon-delete"></div><div style="display:inline;" data-val="' + myresp.pid + '" data-id="' + myresp.pdid + '" class="selectable">' + myresp.reference + '</div></td>' +
|
||||||
|
'<td>' + myresp.description + '</td>' +
|
||||||
|
'<td><div class="editableNumber getProduitsById" style="display:inline;" data-modifier="getProduitsById" data-table="produit_devis" data-column="quantite" data-id=' + myresp.pdid + '>' + myresp.quantite + '</div> </td>' +
|
||||||
|
'<td>' + cur.format(myresp.prix_unitaire) + '</td>' +
|
||||||
|
'<td>' + cur.format((myresp.quantite * myresp.prix_unitaire)) + '</td></tr>');
|
||||||
|
total += (myresp.quantite * myresp.prix_unitaire);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#totaldevis tbody").empty();
|
||||||
|
getGlobal(devisId);
|
||||||
|
}).fail(function (response, code) {
|
||||||
|
showError(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -28,25 +28,28 @@ export function updateOrderDate(orderId,dateValue) {
|
|||||||
/**
|
/**
|
||||||
* Get order products
|
* Get order products
|
||||||
*/
|
*/
|
||||||
export function getOrderProductsByOrderId(orderId) {
|
export function getOrderItemsByOrderId(orderId) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: baseUrl + '/order/'+orderId+'/products',
|
url: baseUrl + '/order/'+orderId+'/items',
|
||||||
type: 'PROPFIND',
|
type: 'PROPFIND',
|
||||||
async: false,
|
async: false,
|
||||||
contentType: 'application/json'
|
contentType: 'application/json'
|
||||||
}).done(function (response, code) {
|
}).done(function (response, code) {
|
||||||
$('#orderProducts tbody').empty();
|
$('#orderItems tbody').empty();
|
||||||
|
|
||||||
$.each(JSON.parse(response), function (arrayID, myresp) {
|
$.each(JSON.parse(response), function (arrayID, myresp) {
|
||||||
$('#orderProducts tbody').append(
|
$('#orderItems tbody').append(
|
||||||
'<tr><td><div data-modifier="getOrderProductsByOrderId" data-id="' + myresp.order_product_id + '" data-table="order_product" class="deleteItem icon-delete"></div><div style="display:inline;">' + myresp.produit_reference + '</div></td>' +
|
'<tr>' +
|
||||||
'<td>' + myresp.produit_description + '</td>' +
|
'<td>'+
|
||||||
'<td><div style="display:inline;" data-modifier="getProduitsById">' + myresp.order_product_quantity + '</div> </td>' +
|
'<div data-modifier="getOrderItemsByOrderId" data-id="' + myresp.order_item_id + '" data-table="order_item" class="deleteItem icon-delete"></div>'+
|
||||||
'<td>' + cur.format(myresp.produit_ht_price) + '</td>' +
|
'<div class="selectableOrderItem" data-order-item-id="' + myresp.order_item_id +'" data-order-product-id="' + myresp.order_product_id + '" data-order-id="' + orderId + '" style="display:inline;">' + myresp.order_product_reference + '</div></td>' +
|
||||||
'<td>' + cur.format((myresp.order_product_quantity * myresp.produit_ht_price)) + '</td></tr>');
|
'<td>' + myresp.order_product_label + '</td>' +
|
||||||
|
'<td><div style="display:inline;" data-modifier="getOrderItemsByOrderId">' + myresp.order_item_quantity + '</div> </td>' +
|
||||||
|
'<td>' + cur.format(myresp.order_product_ht_amount) + '</td>' +
|
||||||
|
'<td>' + cur.format((myresp.order_item_quantity * myresp.order_product_ht_amount)) + '</td></tr>');
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#totalOrderProducts tbody").empty();
|
$("#totalOrderItems tbody").empty();
|
||||||
getTotalAmountOfOrder(orderId);
|
getTotalAmountOfOrder(orderId);
|
||||||
}).fail(function (response, code) {
|
}).fail(function (response, code) {
|
||||||
showError(response);
|
showError(response);
|
||||||
@ -64,8 +67,8 @@ export function getTotalAmountOfOrder(orderId) {
|
|||||||
contentType: 'application/json'
|
contentType: 'application/json'
|
||||||
}).done((function (totalAmountResult) {
|
}).done((function (totalAmountResult) {
|
||||||
var totalAmount = JSON.parse(totalAmountResult);
|
var totalAmount = JSON.parse(totalAmountResult);
|
||||||
$('#totalOrderProducts tbody').empty();
|
$('#totalOrderItems tbody').empty();
|
||||||
$('#totalOrderProducts tbody').append(
|
$('#totalOrderItems tbody').append(
|
||||||
'<tr>'+
|
'<tr>'+
|
||||||
'<td style="text-align:center;">' + cur.format(totalAmount.totalHt)+'</td>'+
|
'<td style="text-align:center;">' + cur.format(totalAmount.totalHt)+'</td>'+
|
||||||
'<td id="tva" style="text-align:center;">' + totalAmount.tva + ' %</td>'+
|
'<td id="tva" style="text-align:center;">' + totalAmount.tva + ' %</td>'+
|
||||||
@ -73,3 +76,28 @@ export function getTotalAmountOfOrder(orderId) {
|
|||||||
'<td style="text-align:center;">' + cur.format(Math.round((totalAmount.totalHt * (totalAmount.tva + 100))) / 100) + '</td></tr>');
|
'<td style="text-align:center;">' + cur.format(Math.round((totalAmount.totalHt * (totalAmount.tva + 100))) / 100) + '</td></tr>');
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*} select
|
||||||
|
* @param {*} orderItemId
|
||||||
|
* @param {*} orderProductId
|
||||||
|
*/
|
||||||
|
export function loadOrderProductIntoSelect(selectSelector, orderItemId, orderProductId,orderId) {
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl + '/orderProduct/list',
|
||||||
|
type: 'PROPFIND',
|
||||||
|
contentType: 'application/json'
|
||||||
|
}).done(function (response) {
|
||||||
|
selectSelector.append('<option data-table="order_item" data-column="fk_order_item_id" data-val="' + orderProductId + '" data-id="' + orderItemId + '">'+t('gestion','Cancel')+'</option>');
|
||||||
|
$.each(JSON.parse(response), function (arrayID, myresp) {
|
||||||
|
var selected = "";
|
||||||
|
if (orderProductId == myresp.id) {
|
||||||
|
selected = "selected";
|
||||||
|
}
|
||||||
|
selectSelector.append('<option ' + selected + ' data-table="order_item" data-column="fk_order_item_id" data-order-id="' + orderId + '" data-val="' + myresp.id + '" data-id="' + orderItemId + '">' + myresp.reference + '</option>');
|
||||||
|
});
|
||||||
|
}).fail(function (response, code) {
|
||||||
|
showError(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
@ -4,11 +4,21 @@ import "../css/mycss.css";
|
|||||||
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
||||||
import "./listener/main_listener";
|
import "./listener/main_listener";
|
||||||
import "./listener/orderListener";
|
import "./listener/orderListener";
|
||||||
import { getOrderProductsByOrderId } from "./modules/order/orderAjaxRequest.mjs";
|
import { getProduitsByDevisId } from "./modules/ajaxRequest.mjs";
|
||||||
|
import { getOrderItemsByOrderId } from "./modules/order/orderAjaxRequest.mjs";
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", function () {
|
window.addEventListener("DOMContentLoaded", function () {
|
||||||
globalConfiguration();
|
globalConfiguration();
|
||||||
|
|
||||||
const orderId = $("#orderId").data("id");
|
const orderId = $("#orderId").data("id");
|
||||||
getOrderProductsByOrderId(orderId);
|
const devisId = $("#devisId").data("id");
|
||||||
|
console.log(devisId);
|
||||||
|
const isOrderDevis = devisId != null;
|
||||||
|
|
||||||
|
if(isOrderDevis){
|
||||||
|
getProduitsByDevisId(devisId);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
getOrderItemsByOrderId(orderId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
@ -1,12 +1,48 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use OCA\Gestion\Constants\OrderTypeConstant;
|
||||||
$order = $_['order'];
|
$order = $_['order'];
|
||||||
$configuration = $_['configuration'];
|
$configuration = $_['configuration'];
|
||||||
|
$isOrderDevis = $order->fk_order_type_key == OrderTypeConstant::ORDER_TYPE_DEVIS;
|
||||||
|
$isOrderPurchase = $order->fk_order_type_key == OrderTypeConstant::ORDER_TYPE_PURCHASE;
|
||||||
$orderComment = $order->order_comment == null || $order->order_comment == "" ? "-": $order->order_comment;
|
$orderComment = $order->order_comment == null || $order->order_comment == "" ? "-": $order->order_comment;
|
||||||
|
|
||||||
|
$clientCompany = $isOrderDevis ?
|
||||||
|
$order->client_entreprise :
|
||||||
|
"FOURNISSEUR";
|
||||||
|
|
||||||
|
$clientFullName = $isOrderDevis ?
|
||||||
|
$order->client_prenom . " " . $order->client_nom :
|
||||||
|
$order->provider_name . " " . $order->provider_last_name;
|
||||||
|
|
||||||
|
$clientAddress = $isOrderDevis ?
|
||||||
|
$order->client_adresse :
|
||||||
|
$order->provider_address.' '.$order->provider_city;
|
||||||
|
|
||||||
|
$clientEmail = $isOrderDevis ?
|
||||||
|
$order->client_mail :
|
||||||
|
$order->provider_email;
|
||||||
|
|
||||||
|
$clientPhone = $isOrderDevis ?
|
||||||
|
$order->client_phone :
|
||||||
|
$order->provider_phone;
|
||||||
|
|
||||||
|
$clientSiret = $isOrderDevis ?
|
||||||
|
$order->client_legal_one :
|
||||||
|
$order->provider_company_name;
|
||||||
?>
|
?>
|
||||||
<div class="bootstrap-iso">
|
<div class="bootstrap-iso">
|
||||||
|
<div id="orderId" data-id="<?php echo $order->id; ?>"></div>
|
||||||
|
<?php if($isOrderDevis){
|
||||||
|
?>
|
||||||
|
<div id="devisId" style="display:none;" data-id="<?php echo $order->fk_devis_id; ?>"></div>
|
||||||
|
<?php } ?>
|
||||||
<h2 class="mt-3 mb-3 text-center"> <?php p($l->t('Commande'));?>
|
<h2 class="mt-3 mb-3 text-center"> <?php p($l->t('Commande'));?>
|
||||||
<div id="orderId" style="display:inline" data-id="<?php echo $order->id; ?>">sur le defunt <?php echo $order->defunt_nom; ?></div>
|
<?php if($isOrderDevis) {
|
||||||
<span>(</span> <div style="display:inline"><?php echo $order->lieu_nom; ?>)</div>
|
?>
|
||||||
|
<div style="display:inline">sur le defunt <?php echo $order->defunt_nom; ?></div>
|
||||||
|
<span>(</span> <div style="display:inline"><?php echo $order->lieu_nom; ?>)</div>
|
||||||
|
<?php } ?>
|
||||||
</h2>
|
</h2>
|
||||||
<hr />
|
<hr />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -30,16 +66,18 @@
|
|||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-5 h-100 m-0" style="min-height:250px;">
|
<div class="col-5 h-100 m-0" style="min-height:250px;">
|
||||||
<h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('TO'));?> <span><?php echo $order->client_entreprise; ?></span></h5>
|
<h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('TO'));?> <span><?php echo $clientCompany; ?></span></h5>
|
||||||
<p style="min-height:180px;" class="p-3 m-0 h-100 text-center text-dark text-center border border-top-0 border-2 border-dark">
|
<p style="min-height:180px;" class="p-3 m-0 h-100 text-center text-dark text-center border border-top-0 border-2 border-dark">
|
||||||
<span><?php echo $order->client_prenom . " " . $order->client_nom; ?></span><br/>
|
<span><?php echo $clientFullName; ?></span><br/>
|
||||||
<span><?php echo $order->client_adresse; ?></span><br/>
|
<span><?php echo $clientAddress; ?></span><br/>
|
||||||
<span><?php echo $order->client_mail; ?></span><br/>
|
<span><?php echo $clientEmail; ?></span><br/>
|
||||||
<span><?php echo $order->client_phone; ?></span><br/>
|
<span><?php echo $clientPhone; ?></span><br/>
|
||||||
<span><?php echo $order->client_legal_one; ?></span><br/>
|
<span><?php echo $clientSiret; ?></span><br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if($isOrderDevis){
|
||||||
|
?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md">
|
<div class="col col-md">
|
||||||
<div class="col col-xl text-center">
|
<div class="col col-xl text-center">
|
||||||
@ -47,8 +85,9 @@
|
|||||||
<span>Lieu : <b><?php echo $order->lieu_nom;?> (<?php echo $order->lieu_adresse;?>)</b>
|
<span>Lieu : <b><?php echo $order->lieu_nom;?> (<?php echo $order->lieu_adresse;?>)</b>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr/>
|
|
||||||
</div>
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
<hr/>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md">
|
<div class="col col-md">
|
||||||
<label class="fw-bold">Commentaires :</label>
|
<label class="fw-bold">Commentaires :</label>
|
||||||
@ -63,11 +102,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
<div><h2>Articles</h2></div>
|
<div><h2>Articles</h2></div>
|
||||||
<button id="addProductToOrder" type="button" class="mb-2 btn btn-outline-success">Ajouter un article</button>
|
<?php if($isOrderPurchase){?>
|
||||||
|
<button id="addOrderItems" type="button" class="mb-2 btn btn-outline-success">Ajouter un article</button>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="orderProducts" class="table table-striped">
|
<?php
|
||||||
|
$tableProductId = $isOrderDevis ?
|
||||||
|
"produits" :
|
||||||
|
"orderItems";
|
||||||
|
?>
|
||||||
|
<table id="<?php echo $tableProductId ?>" class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php p($l->t('Reference'));?></th>
|
<th><?php p($l->t('Reference'));?></th>
|
||||||
@ -86,7 +134,12 @@
|
|||||||
<button id="exportOrderToPdf" type="button" class="mb-2 btn btn-outline-success"><?php p($l->t('Save in Nextcloud'));?></button>
|
<button id="exportOrderToPdf" type="button" class="mb-2 btn btn-outline-success"><?php p($l->t('Save in Nextcloud'));?></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-0 table-responsive">
|
<div class="mt-0 table-responsive">
|
||||||
<table id="totalOrderProducts" class="table table-striped table-xl">
|
<?php
|
||||||
|
$tableTotalProductAmountId = $isOrderDevis?
|
||||||
|
"totaldevis" :
|
||||||
|
"totalOrderItems";
|
||||||
|
?>
|
||||||
|
<table id="<?php echo $tableTotalProductAmountId ?>" class="table table-striped table-xl">
|
||||||
<thead class="bg-dark text-white">
|
<thead class="bg-dark text-white">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-center"><?php p($l->t('Total without VAT'));?></th>
|
<th class="text-center"><?php p($l->t('Total without VAT'));?></th>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user