codesniffer

This commit is contained in:
Florian Henry 2014-02-23 20:10:05 +01:00
parent 4cbdf32ae6
commit ec8ad9f8bb
5 changed files with 4543 additions and 5478 deletions

View File

@ -94,9 +94,7 @@ if ($id > 0 || ! empty($ref)) {
} }
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array ( $hookmanager->initHooks(array('propalcard'));
'propalcard'
));
$permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php
@ -104,10 +102,9 @@ $permissionnote = $user->rights->propale->creer; // Used by the include of actio
* Actions * Actions
*/ */
$parameters = array ( $parameters = array('socid' => $socid);
'socid' => $socid $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
); // hooks
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once
@ -634,9 +631,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
$prodcustprice = new Productcustomerprice($db); $prodcustprice = new Productcustomerprice($db);
$filter = array ( $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->client->id);
't.fk_product' => $prod->id,'t.fk_soc' => $object->client->id
);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result) { if ($result) {
@ -1026,13 +1021,10 @@ else if ($action == 'down' && $user->rights->propal->creer) {
if (! $error) { if (! $error) {
// Actions on extra fields (by external module or standard code) // Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !! // FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array ( $hookmanager->initHooks(array('propaldao'));
'propaldao' $parameters = array('id' => $object->id);
)); $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been
$parameters = array ( // modified by
'id' => $object->id
);
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
// some hooks // some hooks
if (empty($reshook)) { if (empty($reshook)) {
$result = $object->insertExtraFields(); $result = $object->insertExtraFields();
@ -1243,10 +1235,9 @@ if ($action == 'create') {
} }
// Other attributes // Other attributes
$parameters = array ( $parameters = array('colspan' => ' colspan="3"');
'colspan' => ' colspan="3"' $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified
); // by
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
// hook // hook
if (empty($reshook) && ! empty($extrafields->attribute_label)) { if (empty($reshook) && ! empty($extrafields->attribute_label)) {
print $object->showOptionals($extrafields, 'edit'); print $object->showOptionals($extrafields, 'edit');
@ -1361,11 +1352,9 @@ if ($action == 'create') {
$formquestion = array( $formquestion = array(
// 'text' => $langs->trans("ConfirmClone"), // 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' =>
array ( // 1),
'type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)') array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')));
)
);
// Paiement incomplet. On demande si motif = escompte ou autre // Paiement incomplet. On demande si motif = escompte ou autre
$formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ClonePropal'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ClonePropal'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
} }
@ -1414,10 +1403,9 @@ if ($action == 'create') {
} }
if (! $formconfirm) { if (! $formconfirm) {
$parameters = array ( $parameters = array('lineid' => $lineid);
'lineid' => $lineid $formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified
); // by
$formconfirm = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by
// hook // hook
} }
@ -1685,10 +1673,9 @@ if ($action == 'create') {
// Other attributes (TODO Move this into an include) // Other attributes (TODO Move this into an include)
$res = $object->fetch_optionals($object->id, $extralabels); $res = $object->fetch_optionals($object->id, $extralabels);
$parameters = array ( $parameters = array('colspan' => ' colspan="3"');
'colspan' => ' colspan="3"' $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified
); // by
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by
// hook // hook
if (empty($reshook) && ! empty($extrafields->attribute_label)) { if (empty($reshook) && ! empty($extrafields->attribute_label)) {
foreach ($extrafields->attribute_label as $key => $label) { foreach ($extrafields->attribute_label as $key => $label) {
@ -1705,9 +1692,7 @@ if ($action == 'create') {
print ' class="fieldrequired"'; print ' class="fieldrequired"';
print '>' . $label . '</td><td colspan="5">'; print '>' . $label . '</td><td colspan="5">';
// Convert date into timestamp format // Convert date into timestamp format
if (in_array($extrafields->attribute_type [$key], array ( if (in_array($extrafields->attribute_type [$key], array('date','datetime'))) {
'date','datetime'
))) {
$value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]); $value = isset($_POST ["options_" . $key]) ? dol_mktime($_POST ["options_" . $key . "hour"], $_POST ["options_" . $key . "min"], 0, $_POST ["options_" . $key . "month"], $_POST ["options_" . $key . "day"], $_POST ["options_" . $key . "year"]) : $db->jdate($object->array_options ['options_' . $key]);
} }
@ -1830,7 +1815,8 @@ if ($action == 'create') {
} }
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been
// modified
// by hook // by hook
} }
} }
@ -1888,7 +1874,8 @@ if ($action == 'create') {
} }
// Create event // Create event
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
// "workflow" action so should appears somewhere else on // "workflow" action so should appears somewhere
// else on
// page. // page.
{ {
print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>'; print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddAction") . '</a>';

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -21,14 +21,20 @@
* \file htdocs/product/ajax/products.php * \file htdocs/product/ajax/products.php
* \brief File to return Ajax response on product list request * \brief File to return Ajax response on product list request
*/ */
if (! defined('NOTOKENRENEWAL'))
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal define('NOTOKENRENEWAL', 1); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREMENU'))
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); define('NOREQUIREMENU', '1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIREHTML'))
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); define('NOREQUIREHTML', '1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOREQUIREAJAX'))
if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); define('NOREQUIREAJAX', '1');
if (! defined('NOREQUIRESOC'))
define('NOREQUIRESOC', '1');
if (! defined('NOCSRFCHECK'))
define('NOCSRFCHECK', '1');
if (empty($_GET ['keysearch']) && ! defined('NOREQUIREHTML'))
define('NOREQUIREHTML', '1');
require '../../main.inc.php'; require '../../main.inc.php';
@ -52,16 +58,14 @@ $price_by_qty_rowid=GETPOST('pbq', 'int');
dol_syslog(join(',', $_GET)); dol_syslog(join(',', $_GET));
// print_r($_GET); // print_r($_GET);
if (! empty($action) && $action == 'fetch' && ! empty($id)) if (! empty($action) && $action == 'fetch' && ! empty($id)) {
{
require DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
$outjson = array(); $outjson = array();
$object = new Product($db); $object = new Product($db);
$ret = $object->fetch($id); $ret = $object->fetch($id);
if ($ret > 0) if ($ret > 0) {
{
$outref = $object->ref; $outref = $object->ref;
$outlabel = $object->label; $outlabel = $object->label;
$outdesc = $object->description; $outdesc = $object->description;
@ -72,18 +76,18 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
$found = false; $found = false;
// Price by qty // Price by qty
if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a particular price related to qty if (! empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))) // If we need a
// particular price related
// to qty
{ {
$sql = "SELECT price, unitprice, quantity, remise_percent"; $sql = "SELECT price, unitprice, quantity, remise_percent";
$sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty "; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty ";
$sql .= " WHERE rowid=" . $price_by_qty_rowid . ""; $sql .= " WHERE rowid=" . $price_by_qty_rowid . "";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
if ($objp) if ($objp) {
{
$found = true; $found = true;
$outprice_ht = price($objp->unitprice); $outprice_ht = price($objp->unitprice);
$outprice_ttc = price($objp->unitprice * (1 + ($object->tva_tx / 100))); $outprice_ttc = price($objp->unitprice * (1 + ($object->tva_tx / 100)));
@ -96,7 +100,8 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
} }
// Multiprice // Multiprice
if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price level (from 1 to 6) if (! $found && isset($price_level) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES))) // If we need a particular price
// level (from 1 to 6)
{ {
$sql = "SELECT price, price_ttc, price_base_type, tva_tx"; $sql = "SELECT price, price_ttc, price_base_type, tva_tx";
$sql .= " FROM " . MAIN_DB_PREFIX . "product_price "; $sql .= " FROM " . MAIN_DB_PREFIX . "product_price ";
@ -107,11 +112,9 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
$sql .= " DESC LIMIT 1"; $sql .= " DESC LIMIT 1";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
if ($objp) if ($objp) {
{
$found = true; $found = true;
$outprice_ht = price($objp->price); $outprice_ht = price($objp->price);
$outprice_ttc = price($objp->price_ttc); $outprice_ttc = price($objp->price_ttc);
@ -128,16 +131,11 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
$prodcustprice = new Productcustomerprice($db); $prodcustprice = new Productcustomerprice($db);
$filter = array ( $filter = array('t.fk_product' => $object->id,'t.fk_soc' => $socid);
't.fk_product' => $object->id,
't.fk_soc'=> $socid
);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result) if ($result) {
{ if (count($prodcustprice->lines) > 0) {
if (count($prodcustprice->lines)>0)
{
$found = true; $found = true;
$outprice_ht = price($prodcustprice->lines [0]->price); $outprice_ht = price($prodcustprice->lines [0]->price);
$outprice_ttc = price($prodcustprice->lines [0]->price_ttc); $outprice_ttc = price($prodcustprice->lines [0]->price_ttc);
@ -147,9 +145,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
} }
} }
if (! $found) {
if (! $found)
{
$outprice_ht = price($object->price); $outprice_ht = price($object->price);
$outprice_ttc = price($object->price_ttc); $outprice_ttc = price($object->price_ttc);
$outpricebasetype = $object->price_base_type; $outpricebasetype = $object->price_base_type;
@ -160,10 +156,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
} }
echo json_encode($outjson); echo json_encode($outjson);
} else {
}
else
{
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
$langs->load("products"); $langs->load("products");
@ -171,30 +164,30 @@ else
top_httphead(); top_httphead();
if (empty($htmlname)) return; if (empty($htmlname))
return;
$match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET)); $match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET));
sort($match); sort($match);
$idprod = (! empty($match [0]) ? $match [0] : ''); $idprod = (! empty($match [0]) ? $match [0] : '');
if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; if (! GETPOST($htmlname) && ! GETPOST($idprod))
return;
// When used from jQuery, the search term is added as GET param "term". // When used from jQuery, the search term is added as GET param "term".
$searchkey = (GETPOST($idprod) ? GETPOST($idprod) : (GETPOST($htmlname) ? GETPOST($htmlname) : '')); $searchkey = (GETPOST($idprod) ? GETPOST($idprod) : (GETPOST($htmlname) ? GETPOST($htmlname) : ''));
$form = new Form($db); $form = new Form($db);
if (empty($mode) || $mode == 1) if (empty($mode) || $mode == 1) {
{
$arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, 2, $outjson, $socid); $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, 2, $outjson, $socid);
} } elseif ($mode == 2) {
elseif ($mode == 2)
{
$arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid); $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid);
} }
$db->close(); $db->close();
if ($outjson) print json_encode($arrayresult); if ($outjson)
print json_encode($arrayresult);
} }
?> ?>

View File

@ -25,7 +25,6 @@
* \ingroup product * \ingroup product
* \brief Page to show product prices * \brief Page to show product prices
*/ */
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
@ -46,7 +45,8 @@ $action = GETPOST('action', 'alpha');
// Security check // Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id)
$socid = $user->societe_id;
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
$object = new Product($db); $object = new Product($db);
@ -55,22 +55,18 @@ $object = new Product($db);
* Actions * Actions
*/ */
if ($action == 'update_price' && ! $_POST["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action == 'update_price' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
{
$result = $object->fetch($id); $result = $object->fetch($id);
// MultiPrix // MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
{
$newprice = ''; $newprice = '';
$newprice_min = ''; $newprice_min = '';
$newpricebase = ''; $newpricebase = '';
$newvat = ''; $newvat = '';
for($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) {
{ if (isset($_POST ["price_" . $i])) {
if (isset($_POST["price_".$i]))
{
$level = $i; $level = $i;
$newprice = price2num($_POST ["price_" . $i], 'MU'); $newprice = price2num($_POST ["price_" . $i], 'MU');
$newprice_min = price2num($_POST ["price_min_" . $i], 'MU'); $newprice_min = price2num($_POST ["price_min_" . $i], 'MU');
@ -82,9 +78,7 @@ if ($action == 'update_price' && ! $_POST["cancel"] && ($user->rights->produit->
break; // We found submited price break; // We found submited price
} }
} }
} } else {
else
{
$level = 0; $level = 0;
$newprice = price2num($_POST ["price"], 'MU'); $newprice = price2num($_POST ["price"], 'MU');
$newprice_min = price2num($_POST ["price_min"], 'MU'); $newprice_min = price2num($_POST ["price_min"], 'MU');
@ -95,26 +89,24 @@ if ($action == 'update_price' && ! $_POST["cancel"] && ($user->rights->produit->
$newpsq = empty($newpsq) ? 0 : $newpsq; $newpsq = empty($newpsq) ? 0 : $newpsq;
} }
if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) {
{
$action = ''; $action = '';
$mesg = '<div class="ok">' . $langs->trans("RecordSaved") . '</div>'; $mesg = '<div class="ok">' . $langs->trans("RecordSaved") . '</div>';
} } else {
else
{
$action = 'edit_price'; $action = 'edit_price';
$mesg = '<div class="error">' . $object->error . '</div>'; $mesg = '<div class="error">' . $object->error . '</div>';
} }
} } else if ($action == 'delete' && $user->rights->produit->supprimer) {
else if ($action == 'delete' && $user->rights->produit->supprimer)
{
$result = $object->log_price_delete($user, $_GET ["lineid"]); $result = $object->log_price_delete($user, $_GET ["lineid"]);
if ($result < 0) $mesg='<div class="error">'.$object->error.'</div>'; if ($result < 0)
$mesg = '<div class="error">' . $object->error . '</div>';
} }
/***************************************************** /**
* ***************************************************
* Price by quantity * Price by quantity
*****************************************************/ * ***************************************************
*/
$error = 0; $error = 0;
if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price, specified as by quantity if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price, specified as by quantity
$result = $object->fetch($id); $result = $object->fetch($id);
@ -139,20 +131,17 @@ if ($action == 'update_price_by_qty') { // Ajout / Mise à jour d'un prix par qu
$remise_percent = price2num(GETPOST('remise_percent')); $remise_percent = price2num(GETPOST('remise_percent'));
$remise = 0; // TODO : allow dicsount by amount when available on documents $remise = 0; // TODO : allow dicsount by amount when available on documents
if (empty($quantity)) if (empty($quantity)) {
{
$error ++; $error ++;
$mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Qty")) . '</div>'; $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Qty")) . '</div>';
} }
if (empty($newprice)) if (empty($newprice)) {
{
$error ++; $error ++;
$mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Price")) . '</div>'; $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Price")) . '</div>';
} }
if (! $error) { if (! $error) {
// Calcul du prix HT et du prix unitaire // Calcul du prix HT et du prix unitaire
if ($object->price_base_type == 'TTC') if ($object->price_base_type == 'TTC') {
{
$price = price2num($newprice) / (1 + ($object->tva_tx / 100)); $price = price2num($newprice) / (1 + ($object->tva_tx / 100));
} }
@ -197,11 +186,12 @@ if ($action == 'delete_all_price_by_qty') {
$result = $db->query($sql); $result = $db->query($sql);
} }
/***************************************************** /**
* ***************************************************
* Price by customer * Price by customer
*****************************************************/ * ****************************************************
if ($action == 'add_customer_price_confirm' && ! $_POST["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) */
{ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$update_child_soc = GETPOST('updatechildprice'); $update_child_soc = GETPOST('updatechildprice');
@ -218,8 +208,7 @@ if ($action == 'add_customer_price_confirm' && ! $_POST["cancel"] && ($user->rig
$result = $prodcustprice->create($user, 0, $update_child_soc); $result = $prodcustprice->create($user, 0, $update_child_soc);
if ($result < 0) if ($result < 0) {
{
setEventMessage($prodcustprice->error, 'errors'); setEventMessage($prodcustprice->error, 'errors');
} else { } else {
setEventMessage($langs->trans('Save'), 'mesgs'); setEventMessage($langs->trans('Save'), 'mesgs');
@ -228,14 +217,12 @@ if ($action == 'add_customer_price_confirm' && ! $_POST["cancel"] && ($user->rig
$action = ''; $action = '';
} }
if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) {
{
// Delete price by customer // Delete price by customer
$prodcustprice->id = GETPOST('lineid'); $prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user); $result = $prodcustprice->delete($user);
if ($result < 0) if ($result < 0) {
{
setEventMessage($prodcustprice->error, 'mesgs'); setEventMessage($prodcustprice->error, 'mesgs');
} else { } else {
setEventMessage($langs->trans('Delete'), 'errors'); setEventMessage($langs->trans('Delete'), 'errors');
@ -243,8 +230,7 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer ||
$action = ''; $action = '';
} }
if ($action == 'update_customer_price_confirm' && ! $_POST["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
{
$update_child_soc = GETPOST('updatechildprice'); $update_child_soc = GETPOST('updatechildprice');
@ -259,8 +245,7 @@ if ($action == 'update_customer_price_confirm' && ! $_POST["cancel"] && ($user->
$result = $prodcustprice->update($user, 0, $update_child_soc); $result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) if ($result < 0) {
{
setEventMessage($prodcustprice->error, 'errors'); setEventMessage($prodcustprice->error, 'errors');
} else { } else {
setEventMessage($langs->trans('Save'), 'mesgs'); setEventMessage($langs->trans('Save'), 'mesgs');
@ -269,15 +254,14 @@ if ($action == 'update_customer_price_confirm' && ! $_POST["cancel"] && ($user->
$action = ''; $action = '';
} }
/* /*
* View * View
*/ */
$form = new Form($db); $form = new Form($db);
if (! empty($id) || ! empty($ref)) $result = $object->fetch($id, $ref); if (! empty($id) || ! empty($ref))
$result = $object->fetch($id, $ref);
llxHeader("", "", $langs->trans("CardProduct" . $object->type)); llxHeader("", "", $langs->trans("CardProduct" . $object->type));
@ -301,8 +285,7 @@ print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->libelle.'</td>';
$isphoto = $object->is_photo_available($conf->product->multidir_output [$object->entity]); $isphoto = $object->is_photo_available($conf->product->multidir_output [$object->entity]);
$nblignes = 5; $nblignes = 5;
if ($isphoto) if ($isphoto) {
{
// Photo // Photo
print '<td valign="middle" align="center" width="30%" rowspan="' . $nblignes . '">'; print '<td valign="middle" align="center" width="30%" rowspan="' . $nblignes . '">';
print $object->show_photos($conf->product->multidir_output [$object->entity], 1, 1, 0, 0, 0, 80); print $object->show_photos($conf->product->multidir_output [$object->entity], 1, 1, 0, 0, 0, 80);
@ -312,54 +295,40 @@ if ($isphoto)
print '</tr>'; print '</tr>';
// MultiPrix // MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
{ if (! empty($socid)) {
if (! empty($socid))
{
$soc = new Societe($db); $soc = new Societe($db);
$soc->id = $socid; $soc->id = $socid;
$soc->fetch($socid); $soc->fetch($socid);
print '<tr><td>' . $langs->trans("SellingPrice") . '</td>'; print '<tr><td>' . $langs->trans("SellingPrice") . '</td>';
if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') if ($object->multiprices_base_type ["$soc->price_level"] == 'TTC') {
{
print '<td>' . price($object->multiprices_ttc ["$soc->price_level"]); print '<td>' . price($object->multiprices_ttc ["$soc->price_level"]);
} } else {
else
{
print '<td>' . price($object->multiprices ["$soc->price_level"]); print '<td>' . price($object->multiprices ["$soc->price_level"]);
} }
if ($object->multiprices_base_type["$soc->price_level"]) if ($object->multiprices_base_type ["$soc->price_level"]) {
{
print ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]); print ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]);
} } else {
else
{
print ' ' . $langs->trans($object->price_base_type); print ' ' . $langs->trans($object->price_base_type);
} }
print '</td></tr>'; print '</td></tr>';
// Prix mini // Prix mini
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>'; print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') if ($object->multiprices_base_type ["$soc->price_level"] == 'TTC') {
{
print price($object->multiprices_min_ttc ["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]); print price($object->multiprices_min_ttc ["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]);
} } else {
else
{
print price($object->multiprices_min ["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]); print price($object->multiprices_min ["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type ["$soc->price_level"]);
} }
print '</td></tr>'; print '</td></tr>';
// TVA // TVA
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->multiprices_tva_tx ["$soc->price_level"], true) . '</td></tr>'; print '<tr><td>' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->multiprices_tva_tx ["$soc->price_level"], true) . '</td></tr>';
} } else {
else for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) {
{
for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{
// TVA // TVA
if ($i == 1) // We show only price for level 1 if ($i == 1) // We show only price for level 1
{ {
@ -368,33 +337,24 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
print '<tr><td>' . $langs->trans("SellingPrice") . ' ' . $i . '</td>'; print '<tr><td>' . $langs->trans("SellingPrice") . ' ' . $i . '</td>';
if ($object->multiprices_base_type["$i"] == 'TTC') if ($object->multiprices_base_type ["$i"] == 'TTC') {
{
print '<td>' . price($object->multiprices_ttc ["$i"]); print '<td>' . price($object->multiprices_ttc ["$i"]);
} } else {
else
{
print '<td>' . price($object->multiprices ["$i"]); print '<td>' . price($object->multiprices ["$i"]);
} }
if ($object->multiprices_base_type["$i"]) if ($object->multiprices_base_type ["$i"]) {
{
print ' ' . $langs->trans($object->multiprices_base_type ["$i"]); print ' ' . $langs->trans($object->multiprices_base_type ["$i"]);
} } else {
else
{
print ' ' . $langs->trans($object->price_base_type); print ' ' . $langs->trans($object->price_base_type);
} }
print '</td></tr>'; print '</td></tr>';
// Prix mini // Prix mini
print '<tr><td>' . $langs->trans("MinPrice") . ' ' . $i . '</td><td>'; print '<tr><td>' . $langs->trans("MinPrice") . ' ' . $i . '</td><td>';
if ($object->multiprices_base_type["$i"] == 'TTC') if ($object->multiprices_base_type ["$i"] == 'TTC') {
{
print price($object->multiprices_min_ttc ["$i"]) . ' ' . $langs->trans($object->multiprices_base_type ["$i"]); print price($object->multiprices_min_ttc ["$i"]) . ' ' . $langs->trans($object->multiprices_base_type ["$i"]);
} } else {
else
{
print price($object->multiprices_min ["$i"]) . ' ' . $langs->trans($object->multiprices_base_type ["$i"]); print price($object->multiprices_min ["$i"]) . ' ' . $langs->trans($object->multiprices_base_type ["$i"]);
} }
print '</td></tr>'; print '</td></tr>';
@ -471,47 +431,37 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
} }
} }
} }
} } else {
else
{
// TVA // TVA
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '</td></tr>'; print '<tr><td>' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '</td></tr>';
// Price // Price
print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>'; print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>';
if ($object->price_base_type == 'TTC') if ($object->price_base_type == 'TTC') {
{
print price($object->price_ttc) . ' ' . $langs->trans($object->price_base_type); print price($object->price_ttc) . ' ' . $langs->trans($object->price_base_type);
} } else {
else
{
print price($object->price) . ' ' . $langs->trans($object->price_base_type); print price($object->price) . ' ' . $langs->trans($object->price_base_type);
} }
print '</td></tr>'; print '</td></tr>';
// Price minimum // Price minimum
print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>'; print '<tr><td>' . $langs->trans("MinPrice") . '</td><td>';
if ($object->price_base_type == 'TTC') if ($object->price_base_type == 'TTC') {
{
print price($object->price_min_ttc) . ' ' . $langs->trans($object->price_base_type); print price($object->price_min_ttc) . ' ' . $langs->trans($object->price_base_type);
} } else {
else
{
print price($object->price_min) . ' ' . $langs->trans($object->price_base_type); print price($object->price_min) . ' ' . $langs->trans($object->price_base_type);
} }
print '</td></tr>'; print '</td></tr>';
// Price by quantity // Price by quantity
if($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) if ($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) {
{
print '<tr><td>' . $langs->trans("PriceByQuantity"); print '<tr><td>' . $langs->trans("PriceByQuantity");
if ($object->prices_by_qty [0] == 0) { if ($object->prices_by_qty [0] == 0) {
print '&nbsp;<a href="' . $_SERVER ['PHP_SELF'] . '?id=' . $object->id . '&action=activate_price_by_qty&level=1">' . $langs->trans("Activate"); print '&nbsp;<a href="' . $_SERVER ['PHP_SELF'] . '?id=' . $object->id . '&action=activate_price_by_qty&level=1">' . $langs->trans("Activate");
} }
print '</td><td>'; print '</td><td>';
if($object->prices_by_qty[0] == 1) if ($object->prices_by_qty [0] == 1) {
{
print '<table width="50%" class="noborder">'; print '<table width="50%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans("PriceByQuantityRange") . '</td>'; print '<td>' . $langs->trans("PriceByQuantityRange") . '</td>';
@ -520,8 +470,7 @@ else
print '<td align="right">' . $langs->trans("Discount") . '</td>'; print '<td align="right">' . $langs->trans("Discount") . '</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
foreach ($object->prices_by_qty_list[0] as $ii=> $prices) foreach ($object->prices_by_qty_list [0] as $ii => $prices) {
{
if ($action == 'edit_price_by_qty' && $rowid == $prices ['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) { if ($action == 'edit_price_by_qty' && $rowid == $prices ['rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) {
print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="action" value="update_price_by_qty">'; print '<input type="hidden" name="action" value="update_price_by_qty">';
@ -590,36 +539,29 @@ if (! empty($mesg)) {
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);
} }
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Barre d'action */ /* Barre d'action */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if (! $action || $action == 'delete') if (! $action || $action == 'delete') {
{
print "\n" . '<div class="tabsAction">' . "\n"; print "\n" . '<div class="tabsAction">' . "\n";
if ($user->rights->produit->creer || $user->rights->service->creer) if ($user->rights->produit->creer || $user->rights->service->creer) {
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ['PHP_SELF'] . '?action=edit_price&amp;id=' . $object->id . '">' . $langs->trans("UpdatePrice") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ['PHP_SELF'] . '?action=edit_price&amp;id=' . $object->id . '">' . $langs->trans("UpdatePrice") . '</a></div>';
} }
print "\n</div>\n"; print "\n</div>\n";
} }
/* /*
* Edition du prix * Edition du prix
*/ */
if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
{
print_fiche_titre($langs->trans("NewPrice"), '', ''); print_fiche_titre($langs->trans("NewPrice"), '', '');
if (empty($conf->global->PRODUIT_MULTIPRICES)) if (empty($conf->global->PRODUIT_MULTIPRICES)) {
{
print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="update_price">'; print '<input type="hidden" name="action" value="update_price">';
@ -645,12 +587,9 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
$text = $langs->trans('SellingPrice'); $text = $langs->trans('SellingPrice');
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
print '</td><td>'; print '</td><td>';
if ($object->price_base_type == 'TTC') if ($object->price_base_type == 'TTC') {
{
print '<input name="price" size="10" value="' . price($object->price_ttc) . '">'; print '<input name="price" size="10" value="' . price($object->price_ttc) . '">';
} } else {
else
{
print '<input name="price" size="10" value="' . price($object->price) . '">'; print '<input name="price" size="10" value="' . price($object->price) . '">';
} }
print '</td></tr>'; print '</td></tr>';
@ -659,12 +598,9 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<tr><td>'; print '<tr><td>';
$text = $langs->trans('MinPrice'); $text = $langs->trans('MinPrice');
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
if ($object->price_base_type == 'TTC') if ($object->price_base_type == 'TTC') {
{
print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">'; print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">';
} } else {
else
{
print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">'; print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
} }
print '</td></tr>'; print '</td></tr>';
@ -675,11 +611,8 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></center>'; print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></center>';
print '<br></form>'; print '<br></form>';
} } else {
else for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) {
{
for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{
print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; print '<form action="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="update_price">'; print '<input type="hidden" name="action" value="update_price">';
@ -687,14 +620,11 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// VAT // VAT
if ($i == 1) if ($i == 1) {
{
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>'; print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx ["$i"], $mysoc, '', $object->id); print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx ["$i"], $mysoc, '', $object->id);
print '</td></tr>'; print '</td></tr>';
} } else { // We always use the vat rate of price level 1 (A vat rate does not depends on customer)
else
{ // We always use the vat rate of price level 1 (A vat rate does not depends on customer)
print '<input type="hidden" name="tva_tx_' . $i . '" value="' . $object->multiprices_tva_tx [1] . '">'; print '<input type="hidden" name="tva_tx_' . $i . '" value="' . $object->multiprices_tva_tx [1] . '">';
} }
@ -703,12 +633,9 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
$text = $langs->trans('SellingPrice') . ' ' . $i; $text = $langs->trans('SellingPrice') . ' ' . $i;
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
print '</td><td>'; print '</td><td>';
if ($object->multiprices_base_type["$i"] == 'TTC') if ($object->multiprices_base_type ["$i"] == 'TTC') {
{
print '<input name="price_' . $i . '" size="10" value="' . price($object->multiprices_ttc ["$i"]) . '">'; print '<input name="price_' . $i . '" size="10" value="' . price($object->multiprices_ttc ["$i"]) . '">';
} } else {
else
{
print '<input name="price_' . $i . '" size="10" value="' . price($object->multiprices ["$i"]) . '">'; print '<input name="price_' . $i . '" size="10" value="' . price($object->multiprices ["$i"]) . '">';
} }
print $form->select_PriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i); print $form->select_PriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i);
@ -718,12 +645,9 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '<tr><td>'; print '<tr><td>';
$text = $langs->trans('MinPrice') . ' ' . $i; $text = $langs->trans('MinPrice') . ' ' . $i;
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
if ($object->multiprices_base_type["$i"] == 'TTC') if ($object->multiprices_base_type ["$i"] == 'TTC') {
{
print '<td><input name="price_min_' . $i . '" size="10" value="' . price($object->multiprices_min_ttc ["$i"]) . '">'; print '<td><input name="price_min_' . $i . '" size="10" value="' . price($object->multiprices_min_ttc ["$i"]) . '">';
} } else {
else
{
print '<td><input name="price_min_' . $i . '" size="10" value="' . price($object->multiprices_min ["$i"]) . '">'; print '<td><input name="price_min_' . $i . '" size="10" value="' . price($object->multiprices_min ["$i"]) . '">';
} }
print '</td></tr>'; print '</td></tr>';
@ -733,11 +657,9 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} }
} }
} }
// Liste des evolutions du prix // Liste des evolutions du prix
$sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.recuperableonly,"; $sql = "SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.recuperableonly,";
$sql .= " p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,"; $sql .= " p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
@ -747,18 +669,17 @@ $sql.= " ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE fk_product = " . $object->id; $sql .= " WHERE fk_product = " . $object->id;
$sql .= " AND p.entity IN (" . getEntity('productprice', 1) . ")"; $sql .= " AND p.entity IN (" . getEntity('productprice', 1) . ")";
$sql .= " AND p.fk_user_author = u.rowid"; $sql .= " AND p.fk_user_author = u.rowid";
if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES)) $sql.= " AND p.price_level = ".$soc->price_level; if (! empty($socid) && ! empty($conf->global->PRODUIT_MULTIPRICES))
$sql .= " AND p.price_level = " . $soc->price_level;
$sql .= " ORDER BY p.date_price DESC, p.price_level ASC"; $sql .= " ORDER BY p.date_price DESC, p.price_level ASC";
// $sql .= $db->plimit(); // $sql .= $db->plimit();
dol_syslog("sql=" . $sql); dol_syslog("sql=" . $sql);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
if (! $num) if (! $num) {
{
$db->free($result); $db->free($result);
// Il doit au moins y avoir la ligne de prix initial. // Il doit au moins y avoir la ligne de prix initial.
@ -769,8 +690,7 @@ if ($result)
$num = $db->num_rows($result); $num = $db->num_rows($result);
} }
if ($num > 0) if ($num > 0) {
{
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -778,12 +698,10 @@ if ($result)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>'; print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
{
print '<td align="center">' . $langs->trans("MultiPriceLevelsName") . '</td>'; print '<td align="center">' . $langs->trans("MultiPriceLevelsName") . '</td>';
} }
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
{
print '<td align="center">' . $langs->trans("Type") . '</td>'; print '<td align="center">' . $langs->trans("Type") . '</td>';
} }
@ -794,13 +712,13 @@ if ($result)
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>'; print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>'; print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>'; print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
if ($user->rights->produit->supprimer) print '<td align="right">&nbsp;</td>'; if ($user->rights->produit->supprimer)
print '<td align="right">&nbsp;</td>';
print '</tr>'; print '</tr>';
$var = True; $var = True;
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$var = ! $var; $var = ! $var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
@ -808,13 +726,11 @@ if ($result)
print "<td>" . dol_print_date($db->jdate($objp->dp), "dayhour") . "</td>"; print "<td>" . dol_print_date($db->jdate($objp->dp), "dayhour") . "</td>";
// Price level // Price level
if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES)) {
{
print '<td align="center">' . $objp->price_level . "</td>"; print '<td align="center">' . $objp->price_level . "</td>";
} }
// Price by quantity // Price by quantity
if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
{
$type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard'; $type = ($objp->price_by_qty == 1) ? 'PriceByQuantity' : 'Standard';
print '<td align="center">' . $langs->trans($type) . "</td>"; print '<td align="center">' . $langs->trans($type) . "</td>";
} }
@ -830,16 +746,14 @@ if ($result)
print '<td align="right"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $objp->user_id . '">' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $objp->login . '</a></td>'; print '<td align="right"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $objp->user_id . '">' . img_object($langs->trans("ShowUser"), 'user') . ' ' . $objp->login . '</a></td>';
// Action // Action
if ($user->rights->produit->supprimer) if ($user->rights->produit->supprimer) {
{
print '<td align="right">'; print '<td align="right">';
if ($i > 0) if ($i > 0) {
{
print '<a href="' . $_SERVER ["PHP_SELF"] . '?action=delete&amp;id=' . $object->id . '&amp;lineid=' . $objp->rowid . '">'; print '<a href="' . $_SERVER ["PHP_SELF"] . '?action=delete&amp;id=' . $object->id . '&amp;lineid=' . $objp->rowid . '">';
print img_delete(); print img_delete();
print '</a>'; print '</a>';
} } else
else print '&nbsp;'; // Can not delete last price (it's current price) print '&nbsp;'; // Can not delete last price (it's current price)
print '</td>'; print '</td>';
} }
@ -850,9 +764,7 @@ if ($result)
print "</table>"; print "</table>";
print "<br>"; print "<br>";
} }
} } else {
else
{
dol_print_error($db); dol_print_error($db);
} }
@ -875,9 +787,7 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
$sortfield = "soc.nom"; $sortfield = "soc.nom";
// Build filter to diplay only concerned lines // Build filter to diplay only concerned lines
$filter = array ( $filter = array('t.fk_product' => $object->id);
't.fk_product' => $object->id
);
$search_soc = GETPOST('search_soc'); $search_soc = GETPOST('search_soc');
if (! empty($search_soc)) { if (! empty($search_soc)) {
@ -1031,11 +941,7 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print '<br></form>'; print '<br></form>';
} elseif ($action == 'showlog_customer_price') { } elseif ($action == 'showlog_customer_price') {
$filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int'));
$filter = array (
't.fk_product' => $object->id,
't.fk_soc'=> GETPOST('socid','int')
);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = 0; $nbtotalofrecords = 0;
@ -1097,21 +1003,15 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print '<td align="right">'; print '<td align="right">';
print $userstatic->getLoginUrl(1); print $userstatic->getLoginUrl(1);
print '</td>'; print '</td>';
} }
print "</table>"; print "</table>";
} else { } else {
print $langs->trans('None'); print $langs->trans('None');
} }
print "\n" . '<div class="tabsAction">' . "\n"; print "\n" . '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?id=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>';
print "\n</div><br>\n"; print "\n</div><br>\n";
} else { } else {
// View mode // View mode
@ -1186,7 +1086,6 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
print $userstatic->getLoginUrl(1); print $userstatic->getLoginUrl(1);
print '</td>'; print '</td>';
// Todo Edit or delete button // Todo Edit or delete button
// Action // Action
if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { if ($user->rights->produit->supprimer || $user->rights->service->supprimer) {
@ -1227,7 +1126,6 @@ if (! empty ( $conf->global->PRODUIT_CUSTOMER_PRICES )) {
} }
} }
llxFooter(); llxFooter();
$db->close(); $db->close();