Skip to content

Commit

Permalink
Module SynergiesTech: task Dolibarr#1039 - Correction de la prise en …
Browse files Browse the repository at this point in the history
…compte du couple donneur d'ordre/bénéficiaire pour les contrats sur l'ajout de produit (commande et demande) et spécifiquement ceux lié a la demande sur celle-ci et affichage du stock sur les lignes de produits select même si il n'y a jamais de mouvement de stock sur l'un d'eux.
  • Loading branch information
kkhelifa-opendsi authored and Alexis LAURIER committed Jan 6, 2021
1 parent 707714d commit ce6113e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
16 changes: 11 additions & 5 deletions htdocs/custom/synergiestech/class/actions_synergiestech.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1284,14 +1284,20 @@ function doActions($parameters, &$object, &$action, $hookmanager)
if (GETPOST('prod_entry_mode') != 'free' && $product_id > 0) {
$langs->load('synergiestech@synergiestech');
// Gat all contracts of the thirdparty
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
$contract_static = new Contrat($this->db);
$contract_static->socid = $object->socid;
$list_contract = $contract_static->getListOfContracts();
if ($conf->companyrelationships->enabled) {
$object->fetch_optionals();
dol_include_once('/synergiestech/lib/synergiestech.lib.php');
$list_contract = synergiestech_fetch_contract($object->socid, $object->array_options['options_companyrelationships_fk_soc_benefactor'], $msg_error);
} else {
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
$contract_static = new Contrat($this->db);
$contract_static->socid = $object->socid;
$list_contract = $contract_static->getListOfContracts();
}

// Get extrafields of the contract
$contract_extrafields = new ExtraFields($this->db);
$contract_extralabels = $contract_extrafields->fetch_name_optionals_label($contract_static->table_element);
$contract_extralabels = $contract_extrafields->fetch_name_optionals_label('contrat');

// Get categories who has the contract formule category in the full path (exclude the contract formule category)
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,9 @@ private function constructProductListOption(&$objp, &$opt, &$optJson, $price_lev
$opt .= ($objp->rowid == $selected) ? ' selected' : '';
$opt .= (isset($objp->is_into_contract_categories) && $objp->is_into_contract_categories == 0) ? ' disabled' : '';
$opt .= (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) ? ' pbq="' . $objp->price_by_qty_rowid . '"' : '';
if (!empty($conf->stock->enabled) && $objp->fk_product_type == 0 && isset($objp->stock)) {
if (!empty($conf->stock->enabled) && $objp->fk_product_type == 0) {
if ($objp->stock > 0) $opt .= ' class="product_line_stock_ok"';
else if ($objp->stock <= 0) $opt .= ' class="product_line_stock_too_low"';
else $opt .= ' class="product_line_stock_too_low"';
}
$opt .= '>';
$opt .= $objp->ref;
Expand Down Expand Up @@ -727,13 +727,13 @@ private function constructProductListOption(&$objp, &$opt, &$optJson, $price_lev
$outtva_tx = $objp->tva_tx;
}

if (!empty($conf->stock->enabled) && isset($objp->stock) && $objp->fk_product_type == 0) {
if (!empty($conf->stock->enabled) && $objp->fk_product_type == 0) {
$opt .= ' - ' . $langs->trans("Stock") . ':' . $objp->stock;

if ($objp->stock > 0) {
$outval .= ' - <span class="product_line_stock_ok">' . $langs->transnoentities("Stock") . ':' . $objp->stock . '</span>';
} elseif ($objp->stock <= 0) {
$outval .= ' - <span class="product_line_stock_too_low">' . $langs->transnoentities("Stock") . ':' . $objp->stock . '</span>';
} else {
$outval .= ' - <span class="product_line_stock_too_low">' . $langs->transnoentities("Stock") . ':' . (isset($objp->stock) ? $objp->stock : 0) . '</span>';
}
}

Expand Down
39 changes: 29 additions & 10 deletions htdocs/custom/synergiestech/core/tpl/objectline_create.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,39 @@
// Get products categories of the contracts list
//------------------------------------------------------------
$mode = 0; // Show mode for orders lines
if ($object->element == 'requestmanager') {
$mode = 1; // Show mode for request manager lines

$object->fetchObjectLinked();
}

// Gat all contracts of the thirdparty
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
$contract_static = new Contrat($this->db);
$contract_static->socid = $object->socid;
$list_contract = $contract_static->getListOfContracts();
if ($conf->companyrelationships->enabled) {
$object->fetch_optionals();
dol_include_once('/synergiestech/lib/synergiestech.lib.php');
$list_contract = synergiestech_fetch_contract($object->socid, $object->array_options['options_companyrelationships_fk_soc_benefactor'], $msg_error);
} else {
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
$contract_static = new Contrat($this->db);
$contract_static->socid = $object->socid;
$list_contract = $contract_static->getListOfContracts();
}

if ($object->element == 'requestmanager') {
$tmp_list = array();
if (isset($object->linkedObjectsIds['contrat']) && is_array($object->linkedObjectsIds['contrat'])) {
foreach ($list_contract as $contract) {
if (in_array($contract->id, $object->linkedObjectsIds['contrat'])) {
$tmp_list[] = $contract;
}
}
}
$list_contract = $tmp_list;
}

// Get extrafields of the contract
$contract_extrafields = new ExtraFields($this->db);
$contract_extralabels = $contract_extrafields->fetch_name_optionals_label($contract_static->table_element);
$contract_extralabels = $contract_extrafields->fetch_name_optionals_label('contrat');

// Get categories who has the contract formule category in the full path (exclude the contract formule category)
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
Expand All @@ -249,7 +272,7 @@
$formules_not_found_list = array();
if (!empty($list_contract)) {
foreach ($list_contract as $contract) {
if (($contract->nbofserviceswait + $contract->nbofservicesopened) > 0 && $contract->statut != 2) {
if ($contract->nbofservicesopened > 0 && $contract->statut != 2) {
$contract->fetch_optionals();
$formule_id = $contract->array_options['options_formule'];
$formule_label = $contract_extrafields->attribute_param['formule']['options'][$formule_id];
Expand All @@ -272,10 +295,6 @@
$tag_categories = array();
$equipment_categories = array();
if ($object->element == 'requestmanager') {
$mode = 1; // Show mode for request manager lines

$object->fetchObjectLinked();

if (isset($object->linkedObjects['equipement']) && is_array($object->linkedObjects['equipement'])) {
foreach ($object->linkedObjects['equipement'] as $equipment) {
if ($equipment->fk_product > 0) {
Expand Down

0 comments on commit ce6113e

Please sign in to comment.