diff --git a/class/competitorprice.class.php b/class/competitorprice.class.php index 3125685..d03bfb3 100644 --- a/class/competitorprice.class.php +++ b/class/competitorprice.class.php @@ -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]; diff --git a/langs/fr_FR/priseo.lang b/langs/fr_FR/priseo.lang index 86551c9..fb49aaa 100644 --- a/langs/fr_FR/priseo.lang +++ b/langs/fr_FR/priseo.lang @@ -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 diff --git a/view/competitorprice/competitorprice_card.php b/view/competitorprice/competitorprice_card.php index 72dcfbb..7cc5e68 100644 --- a/view/competitorprice/competitorprice_card.php +++ b/view/competitorprice/competitorprice_card.php @@ -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; @@ -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'); @@ -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; @@ -208,7 +214,6 @@ $object = $product; } - /* * View */ @@ -275,33 +280,35 @@ } print ''; - 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 '
'; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } - 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()); @@ -311,24 +318,24 @@ $_POST['competitor_datehour'] = $competitor_date['hours']; $_POST['competitor_datemin'] = $competitor_date['minutes']; - print ''; + print '
'; - // 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 '
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print $form->buttonsSaveCancel('Create'); + print $form->buttonsSaveCancel('Create'); - print '
'; + print ''; - $object = $product; - } elseif ($action == 'update_competitor_price') { + $object = $product; + } elseif ($action == 'update_competitor_price') { //Tricks to use common template $product = $object; $object = $competitorPrice; diff --git a/view/competitorprice/competitorprice_list.php b/view/competitorprice/competitorprice_list.php index 7ad3fcb..bb8d560 100644 --- a/view/competitorprice/competitorprice_list.php +++ b/view/competitorprice/competitorprice_list.php @@ -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)) {