Merge branch 'features/feature-product-type' into staging
This commit is contained in:
commit
991ed7120c
@ -129,7 +129,7 @@ return [
|
||||
['name' => 'page#addFactureNumberColumn', 'url' => '/addFactureNumberColumn', 'verb' => 'POST'],
|
||||
['name' => 'page#addClientGroupDiscountFeatureTables', 'url' => '/addClientGroupDiscountFeatureTables', 'verb' => 'POST'],
|
||||
['name' => 'page#addClientGroupFacturationFeatureTables', 'url' => '/addClientGroupFacturationFeatureTables', 'verb' => 'POST'],
|
||||
|
||||
['name' => 'page#addProductTypeTables', 'url' => '/addProductTypeTables', 'verb' => 'POST'],
|
||||
|
||||
//clients discount
|
||||
['name' => 'page#getClientGroupDiscounts', 'url' => '/getClientGroupDiscounts', 'verb' => 'PROPFIND'],
|
||||
@ -156,6 +156,9 @@ return [
|
||||
|
||||
//client group facturation
|
||||
['name' => 'page#getClientGroupFacturations', 'url' => '/client/getClientGroupFacturations', 'verb' => 'PROPFIND'],
|
||||
['name' => 'page#createDefaultClientGroupFacturation', 'url' => '/client/createDefaultClientGroupFacturation', 'verb' => 'POST']
|
||||
['name' => 'page#createDefaultClientGroupFacturation', 'url' => '/client/createDefaultClientGroupFacturation', 'verb' => 'POST'],
|
||||
|
||||
//producttype
|
||||
['name' => 'page#getProductTypes', 'url' => '/product/getProductTypes', '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
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
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
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -10,4 +10,6 @@ abstract class ProductConstant
|
||||
self::PRODUCT_COVER_TO_RECOVER_REFERENCE,
|
||||
self::PRODUCT_LEAVE_ON_COVER_REFERENCE
|
||||
];
|
||||
const PRODUCT_COVER_TYPE_KEY = "cover";
|
||||
const PRODUCT_COVER_TYPE_NAME = "Housse";
|
||||
}
|
||||
@ -2990,4 +2990,26 @@ class PageController extends Controller {
|
||||
catch(\OCP\Files\NotFoundException $e) { }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
*/
|
||||
|
||||
public function addProductTypeTables(){
|
||||
try{
|
||||
$this->myDb->addProductTypeTables();
|
||||
return true;
|
||||
}
|
||||
catch(\OCP\Files\NotFoundException $e) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getProductTypes() {
|
||||
return $this->myDb->getProductTypes();
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,8 @@ class Bdd {
|
||||
"rasage", "presentation_cosmetique", "presentation_sur", "hypodermiques", "hypodermiques_sur", "local", "local_sur", "contenu",
|
||||
"commentaire", "designation", "hypodermiques_text1", "hypodermiques_text2", "qte", "endroit",
|
||||
"fk_client_group_id","fk_produit_id","ht_amount","client_group_name",
|
||||
"fk_client_group_facturation_id","group_facturation_name");
|
||||
"fk_client_group_facturation_id","group_facturation_name",
|
||||
"fk_product_type_id");
|
||||
$this->whiteTable = array(
|
||||
"client", "lieu", "trajet", "devis", "produit_devis", "facture", "produit", "configuration", "ligne_trajet", "thanato", "article", "defunt", "article_devis", "bibliotheque", "bijou_defunt", "obs_defunt", "hypo_defunt",
|
||||
"client_group_discount","client_group",
|
||||
@ -542,8 +543,19 @@ class Bdd {
|
||||
}
|
||||
|
||||
public function getProduits($idNextcloud,$orderDirection = 'DESC'){
|
||||
$sql = "SELECT *
|
||||
FROM ".$this->tableprefix."produit ORDER BY id ". $orderDirection. ";";
|
||||
$sql = "SELECT
|
||||
produit.id,
|
||||
produit.reference,
|
||||
produit.description,
|
||||
produit.prix_unitaire,
|
||||
produit.vat,
|
||||
produit.fk_product_type_id,
|
||||
product_type.id as product_type_id,
|
||||
product_type.product_type_key as product_type_key,
|
||||
product_type.product_type_name as product_type_name
|
||||
FROM ".$this->tableprefix."produit as produit
|
||||
LEFT JOIN ".$this->tableprefix."product_type as product_type on produit.fk_product_type_id = product_type.id
|
||||
ORDER BY produit.id ". $orderDirection. ";";
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
@ -3152,35 +3164,53 @@ class Bdd {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getCoverProducts(){
|
||||
$sqlConditionsPlaceholder = implode(',', array_fill(0, count(ProductConstant::PRODUCT_COVER_REFERENCE_LIST), '?'));
|
||||
private function getProductsByProductTypeKey(string $productTypeKey){
|
||||
$sql = "SELECT
|
||||
produit.id,
|
||||
produit.reference,
|
||||
produit.description
|
||||
FROM ".$this->tableprefix."produit as produit
|
||||
WHERE produit.reference IN ($sqlConditionsPlaceholder)";
|
||||
|
||||
return $this->execSQL($sql,ProductConstant::PRODUCT_COVER_REFERENCE_LIST);
|
||||
LEFT JOIN ".$this->tableprefix."product_type as product_type on produit.fk_product_type_id = product_type.id
|
||||
WHERE product_type.product_type_key = ?;";
|
||||
|
||||
$products = $this->execSQL($sql,[$productTypeKey]);
|
||||
return $products;
|
||||
}
|
||||
|
||||
public function getCoverProducts(){
|
||||
return $this->getProductsByProductTypeKey(ProductConstant::PRODUCT_COVER_TYPE_KEY);
|
||||
}
|
||||
|
||||
private function getProductTypeByKey(string $key){
|
||||
$sql = "SELECT
|
||||
product_type.id,
|
||||
product_type.product_type_name,
|
||||
product_type.product_type_key
|
||||
FROM ".$this->tableprefix."product_type as product_type
|
||||
WHERE product_type.product_type_key = ?;";
|
||||
|
||||
$productType = $this->execSQLNoJsonReturn($sql,[$key]);
|
||||
if(!empty($productType)){
|
||||
return $productType[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getProductCoverByDevisId($devisId){
|
||||
$sqlConditionsPlaceholder = implode(',', array_fill(0, count(ProductConstant::PRODUCT_COVER_REFERENCE_LIST), '?'));
|
||||
|
||||
$coverProductType = $this->getProductTypeByKey(ProductConstant::PRODUCT_COVER_TYPE_KEY);
|
||||
$sql = "SELECT
|
||||
produit_devis.id,
|
||||
produit.id as produit_id,
|
||||
produit.reference,
|
||||
produit.description
|
||||
produit.description,
|
||||
produit.fk_product_type_id
|
||||
FROM ".$this->tableprefix."produit_devis as produit_devis
|
||||
LEFT JOIN ".$this->tableprefix."produit as produit on produit_devis.produit_id = produit.id
|
||||
WHERE produit_devis.devis_id = ? AND
|
||||
produit.reference IN ($sqlConditionsPlaceholder) LIMIT 1";
|
||||
produit.fk_product_type_id = ? LIMIT 1";
|
||||
|
||||
$productCover = $this->execSQLNoJsonReturn($sql,
|
||||
array_merge(
|
||||
[$devisId],
|
||||
ProductConstant::PRODUCT_COVER_REFERENCE_LIST
|
||||
));
|
||||
$productCover = $this->execSQLNoJsonReturn($sql,[$devisId,$coverProductType["id"]]);
|
||||
if($productCover){
|
||||
return $productCover[0];
|
||||
}
|
||||
@ -3421,5 +3451,27 @@ class Bdd {
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
public function addProductTypeTables(){
|
||||
$sql = "CREATE TABLE oc_gestion_product_type (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
product_type_key VARCHAR(255) DEFAULT '',
|
||||
product_type_name VARCHAR(255) DEFAULT ''
|
||||
);";
|
||||
|
||||
$this->execSQLNoData($sql,[]);
|
||||
|
||||
$sql = "ALTER TABLE oc_gestion_produit
|
||||
ADD fk_product_type_id INT NULL;";
|
||||
|
||||
$this->execSQLNoData($sql,[]);
|
||||
|
||||
$sql = "INSERT INTO oc_gestion_product_type (product_type_key,product_type_name) VALUES (?,?);";
|
||||
$this->execSQLNoData($sql,[ProductConstant::PRODUCT_COVER_TYPE_KEY,ProductConstant::PRODUCT_COVER_TYPE_NAME]);
|
||||
}
|
||||
|
||||
public function getProductTypes(){
|
||||
$sql = "SELECT * FROM ".$this->tableprefix."product_type;";
|
||||
$productTypes = $this->execSQL($sql,[]);
|
||||
return $productTypes;
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,6 +69,9 @@ document.body.addEventListener('click', e => {
|
||||
else if(e.target.className.includes("selectCoverProductsList")){
|
||||
Produit.loadCoverProductListIntoSelect(e);
|
||||
}
|
||||
else if(e.target.className.includes("selectProductTypeList")){
|
||||
Produit.loadProductTypeListIntoSelect(e);
|
||||
}
|
||||
else if(e.target.className.includes("loadSelect_listdevis")){
|
||||
Devis.loadDevisList_dnum(e);
|
||||
}else if(e.target.className.includes("loadSelect_listalldevis")){
|
||||
|
||||
@ -13,6 +13,8 @@ export class Produit {
|
||||
this.reference = ((myresp.reference.length === 0) ? '-' : myresp.reference);
|
||||
this.description = ((myresp.description.length === 0) ? '-' : myresp.description);
|
||||
this.prix_unitaire = ((myresp.prix_unitaire.length === 0) ? '-' : myresp.prix_unitaire);
|
||||
this.product_type_name = (( myresp.product_type_name != null && myresp.product_type_name.length > 0) ? myresp.product_type_name : '-');
|
||||
this.fk_product_type_id = myresp.fk_product_type_id;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -24,6 +26,7 @@ export class Produit {
|
||||
'<div class="editable" data-table="produit" data-column="reference" data-id="' + this.id + '">' + this.reference + '</div>',
|
||||
'<div class="editable" data-table="produit" data-column="description" data-id="' + this.id + '">' + this.description + '</div>',
|
||||
'<div class="editableNumeric" data-table="produit" data-column="prix_unitaire" data-id="' + this.id + '">' + cur.format(this.prix_unitaire) + '</div>',
|
||||
'<div class="selectProductTypeList" data-table="produit" data-column="fk_product_type_id" data-id="' + this.id + '" data-current="' + this.fk_product_type_id + '">' + this.product_type_name + '</div>',
|
||||
'<div data-modifier="produit" data-id=' + this.id + ' data-table="produit" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div>'
|
||||
];
|
||||
return myrow;
|
||||
@ -193,4 +196,68 @@ export class Produit {
|
||||
e.target.appendChild(selectElement);
|
||||
});
|
||||
}
|
||||
|
||||
static getProductTypeList(callback){
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open('PROPFIND', baseUrl + '/product/getProductTypes', true);
|
||||
oReq.setRequestHeader("Content-Type", "application/json");
|
||||
oReq.onload = function(e){
|
||||
if (this.status == 200) {
|
||||
callback(JSON.parse(this.response));
|
||||
}else{
|
||||
showError(this.response);
|
||||
}
|
||||
};
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} lid
|
||||
*/
|
||||
static loadProductTypeListIntoSelect(e){
|
||||
Produit.getProductTypeList(response => {
|
||||
|
||||
var selectElement = document.createElement("select");
|
||||
selectElement.dataset.current = e.target.dataset.current;
|
||||
selectElement.dataset.id = e.target.dataset.id;
|
||||
selectElement.dataset.old = e.target.innerHTML;
|
||||
|
||||
selectElement.addEventListener("change", el=>{
|
||||
if(el.target.value != 0){
|
||||
updateDB(el.target.parentElement.dataset.table,
|
||||
el.target.parentElement.dataset.column,
|
||||
el.target.value,
|
||||
el.target.parentElement.dataset.id
|
||||
);
|
||||
|
||||
var parentElement = el.target.parentElement
|
||||
parentElement.innerHTML = el.target.options[el.target.selectedIndex].text;
|
||||
parentElement.dataset.current = el.target.value;
|
||||
}else{
|
||||
var parentElement = el.target.parentElement
|
||||
parentElement.innerHTML = el.target.dataset.old
|
||||
}
|
||||
});
|
||||
|
||||
var option = document.createElement("option");
|
||||
option.value = 0;
|
||||
option.text = t('gestion', 'Cancel');
|
||||
selectElement.appendChild(option);
|
||||
|
||||
JSON.parse(response).forEach(myresp => {
|
||||
var txt = document.createElement("textarea");
|
||||
txt.innerHTML = myresp.product_type_name;
|
||||
var option = document.createElement("option");
|
||||
option.value = myresp.id;
|
||||
option.text = txt.value;
|
||||
selectElement.appendChild(option);
|
||||
});
|
||||
|
||||
checkSelectPurJs(selectElement);
|
||||
|
||||
e.target.innerHTML = ''
|
||||
e.target.appendChild(selectElement);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
<th><?php p($l->t('Nom'));?></th>
|
||||
<th><?php p($l->t('Designation'));?></th>
|
||||
<th><?php p($l->t('Unit price without VAT'));?></th>
|
||||
<th><?php p($l->t('Type'));?></th>
|
||||
<th><?php p($l->t('Actions'));?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user