Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion class/competitorprice.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public function getCompetitorPriceByAmountHT(): array

$arrayCompetitorPriceByAmountHT = [];
$competitorPrices = $this->fetchAll('', '', 0, 0, ['customsql' => 't.status = ' . self::STATUS_VALIDATED . ' AND t.amount_ht IS NOT NULL AND t.fk_product = ' . GETPOST('id')]);
$averageAmountHT = $this->getAverage(GETPOST('id'));
$averageAmountHT = $this->getAverage(GETPOST('fromid'));
if (is_array($competitorPrices) && !empty($competitorPrices)) {
foreach ($competitorPrices as $competitorPrice) {
$arrayCompetitorPriceByAmountHT[] = [dol_print_date($competitorPrice->date_creation, 'dayhour', 'tzuser'), $competitorPrice->amount_ht, $averageAmountHT];
Expand Down
1 change: 1 addition & 0 deletions langs/fr_FR/priseo.lang
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ DeleteProductCompetitorPrice = Suppression du prix concurrent
NewCompetitorPrice = Nouveaux prix concurrent
ModifyCompetitorPrice = Modifier le prix concurrent
CompetitorPriceEvolutionOverTime = Évolution du prix dans le temps
CompetitorpriceList = Liste des prix concurrent
89 changes: 48 additions & 41 deletions view/competitorprice/competitorprice_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';

// Load Saturne libraries
require_once __DIR__ . '/../../saturne/class/saturnedashboard.class.php';
require_once __DIR__ . '/../../../saturne/class/saturnedashboard.class.php';

require_once __DIR__ . '/../class/competitorprice.class.php';
require_once __DIR__ . '/../core/modules/priseo/competitorprice/mod_competitorprice_standard.php';
require_once __DIR__ . '/../../class/competitorprice.class.php';
require_once __DIR__ . '/../../core/modules/priseo/competitorprice/mod_competitorprice_standard.php';

// Global variables definitions
global $conf, $db, $hookmanager, $langs, $user;
Expand All @@ -50,7 +50,7 @@
$langs->loadLangs(['priseo@priseo', 'other']);

// Get parameters
$id = GETPOST('id', 'int');
$id = GETPOST('fromid', 'int');
$rowid = GETPOST('rowid', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
Expand Down Expand Up @@ -179,20 +179,26 @@

//Tricks to use common template
$product = $object;
$object = $competitorPrice;
$object = $competitorPrice;
if (empty($object->id)) {
$object->fk_product = $product->id;
$object->fk_product = $product->id;
}

// Action to add record
if ($action == 'add' && $permissiontoadd) {
$object->ref = $refCompetitorPriceMod->getNextValue($object);
$object->ref = $refCompetitorPriceMod->getNextValue($object);
$object->fk_product = GETPOST("product", "int");
$object->competitor_date = dol_now();

$competitorPrices = $object->fetchAll('', '', 0, 0, ['customsql' => 't.fk_soc = ' . GETPOST('fk_soc') . ' AND t.fk_product = ' . $object->fk_product]);
if (is_array($competitorPrices) && !empty($competitorPrices)) {
foreach ($competitorPrices as $competitorPrice) {
$competitorPrice->setValueFrom('status', 0, '', '', 'int', '', $user);
}
}
setEventMessages('', $langs->trans('RecordCreatedSuccessfully'));
header("Location: competitorprice_list.php?fromid=" . $object->fk_product . '&fromtype=product');
exit;
}

$noback = 1;
Expand All @@ -208,7 +214,6 @@
$object = $product;
}


/*
* View
*/
Expand Down Expand Up @@ -275,33 +280,35 @@
}
print '</div>';

if ($action == 'create_competitor_price') {
//Tricks to use common template
$product = $object;
$object = $competitorPrice;
if ($action == 'create') {
//Tricks to use common template
$product = $object;
$object = $competitorPrice;

if (empty($permissiontoadd)) {
accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1);
exit;
}
if (empty($permissiontoadd)) {
accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1);
exit;
}

print load_fiche_titre($langs->trans('NewCompetitorPrice'), '', 'object_' . $object->picto);
print load_fiche_titre($langs->trans('NewCompetitorPrice'), '', 'object_' . $object->picto);

print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="id" value="' . $product->id . '">';
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
}
print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="product" value="' . $object->fk_product . '">';
print '<input type="hidden" name="date" value="' . $object->competitor_date . '">';
print '<input type="hidden" name="id" value="' . $product->id . '">';
if ($backtopage) {
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
}

print dol_get_fiche_head();
print dol_get_fiche_head();

// Set some default values
//if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';
// Set some default values
//if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue';

$competitor_date = dol_getdate(dol_now());

Expand All @@ -311,24 +318,24 @@
$_POST['competitor_datehour'] = $competitor_date['hours'];
$_POST['competitor_datemin'] = $competitor_date['minutes'];

print '<table class="border centpercent tableforfieldcreate">';
print '<table class="border centpercent tableforfieldcreate">';

// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';

// Other attributes
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
// Other attributes
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';

print '</table>';
print '</table>';

print dol_get_fiche_end();
print dol_get_fiche_end();

print $form->buttonsSaveCancel('Create');
print $form->buttonsSaveCancel('Create');

print '</form>';
print '</form>';

$object = $product;
} elseif ($action == 'update_competitor_price') {
$object = $product;
} elseif ($action == 'update_competitor_price') {
//Tricks to use common template
$product = $object;
$object = $competitorPrice;
Expand Down
2 changes: 1 addition & 1 deletion view/competitorprice/competitorprice_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
$conf->dol_hide_leftmenu = 1;
}

$title = $langs->trans(ucfirst($object->element) . 'List');
$title = $langs->transnoentities(ucfirst($object->element) . 'List');
saturne_header(0,'', $title, $helpUrl ?? '', '', 0, 0, [], [], '', 'mod-' . $object->module . '-' . $object->element . ' page-list bodyforlist');

if (!empty($fromType)) {
Expand Down