Clean code

This commit is contained in:
Laurent Destailleur 2015-07-12 16:50:27 +02:00
parent 8690b5e70e
commit 11c94a9d3b
3 changed files with 36 additions and 35 deletions

View File

@ -264,7 +264,7 @@ PriceCatalogue=Unique price per product/service
PricingRule=Rules for customer prices
AddCustomerPrice=Add price by customer
ForceUpdateChildPriceSoc=Set same price on customer subsidiaries
PriceByCustomerLog=Price by customer log
PriceByCustomerLog=Log of previous customer prices
MinimumPriceLimit=Minimum price can't be lower then %s
MinimumRecommendedPrice=Minimum recommended price is : %s
PriceExpressionEditor=Price expression editor

View File

@ -232,9 +232,10 @@ class Productcustomerprice extends CommonObject
* @param int $id object
* @return int <0 if KO, >0 if OK
*/
function fetch($id) {
function fetch($id)
{
global $langs;
$sql = "SELECT";
$sql .= " t.rowid,";
@ -293,18 +294,22 @@ class Productcustomerprice extends CommonObject
}
/**
* Load all objects in memory from database
* Load all customer prices in memory from database
*
* @param string $sortorder order
* @param string $sortfield field
* @param int $limit page
* @param int $offset offset
* @param array $filter output
* @return int <0 if KO, >0 if OK
* @param string $sortorder order
* @param string $sortfield field
* @param int $limit page
* @param int $offset offset
* @param array $filter Filter for select
* @return int <0 if KO, >0 if OK
*/
function fetch_all($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array()) {
function fetch_all($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array())
{
global $langs;
if (! empty($sortfield)) $sortfield = "t.rowid";
if (! empty($sortorder)) $sortorder = "DESC";
$sql = "SELECT";
$sql .= " t.rowid,";
@ -347,12 +352,8 @@ class Productcustomerprice extends CommonObject
}
}
if (! empty($sortfield)) {
$sql .= " ORDER BY " . $sortfield . ' ' . $sortorder;
}
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$sql.= $this->db->order($sortfield, $sortorder);
if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
dol_syslog(get_class($this) . "::fetch_all", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -400,16 +401,20 @@ class Productcustomerprice extends CommonObject
/**
* Load all objects in memory from database
*
* @param string $sortorder order
* @param string $sortfield field
* @param int $limit page
* @param int $offset offset
* @param array $filter output
* @return int <0 if KO, >0 if OK
* @param string $sortorder order
* @param string $sortfield field
* @param int $limit page
* @param int $offset offset
* @param array $filter Filter for sql request
* @return int <0 if KO, >0 if OK
*/
function fetch_all_log($sortorder, $sortfield, $limit, $offset, $filter = array()) {
function fetch_all_log($sortorder, $sortfield, $limit, $offset, $filter = array())
{
global $langs;
if (! empty($sortfield)) $sortfield = "t.rowid";
if (! empty($sortorder)) $sortorder = "DESC";
$sql = "SELECT";
$sql .= " t.rowid,";
@ -451,12 +456,8 @@ class Productcustomerprice extends CommonObject
}
}
if (! empty($sortfield)) {
$sql .= " ORDER BY " . $sortfield . ' ' . $sortorder;
}
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$sql.= $this->db->order($sortfield, $sortorder);
if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
dol_syslog(get_class($this) . "::fetch_all_log", LOG_DEBUG);
$resql = $this->db->query($sql);

View File

@ -829,7 +829,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
}
}
// Liste des evolutions du prix
// List of price changes (ordered by descending date)
$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.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
@ -1156,7 +1156,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
}
elseif ($action == 'showlog_customer_price')
{
$filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int'));
// Count total nb of records
@ -1199,6 +1198,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
foreach ($prodcustprice->lines as $line)
{
$var = ! $var;
print "<tr ".$bc[$var].">";
// Date
$staticsoc = new Societe($db);
@ -1237,7 +1237,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
$nbtotalofrecords = $prodcustprice->fetch_all($sortfield, $sortorder, 0, 0, $filter);
}
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);