Clean code

This commit is contained in:
Laurent Destailleur 2019-11-12 10:11:30 +01:00
parent 9fc1c98192
commit c02cd80b75
15 changed files with 65 additions and 53 deletions

View File

@ -536,11 +536,11 @@ if ($action == 'create')
print '<td class="titlefield">' . $langs->trans("Status") . '</td>'; print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
print '<td>'; print '<td>';
if (empty($object->validated)) { if (empty($object->validated)) {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=enable">'; print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>'; print '</a>';
} else { } else {
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=disable">'; print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>'; print '</a>';
} }

View File

@ -57,6 +57,12 @@ class AccountancyCategory // extends CommonObject
*/ */
public $table_element='c_accounting_category'; public $table_element='c_accounting_category';
/**
* @var int ID
* @deprecated
*/
public $rowid;
/** /**
* @var int ID * @var int ID
*/ */

View File

@ -631,7 +631,7 @@ class Propal extends CommonObject
if ($result > 0) if ($result > 0)
{ {
$this->db->commit(); $this->db->commit();
return $this->line->rowid; return $this->line->id;
} }
else else
{ {
@ -772,7 +772,7 @@ class Propal extends CommonObject
$this->line->rang = $rangmax + 1; $this->line->rang = $rangmax + 1;
} }
$this->line->rowid = $rowid; $this->line->id = $rowid;
$this->line->label = $label; $this->line->label = $label;
$this->line->desc = $desc; $this->line->desc = $desc;
$this->line->qty = $qty; $this->line->qty = $qty;

View File

@ -1565,7 +1565,7 @@ class Commande extends CommonOrder
if ($result > 0) if ($result > 0)
{ {
$this->db->commit(); $this->db->commit();
return $this->line->rowid; return $this->line->id;
} }
else else
{ {
@ -3104,7 +3104,7 @@ class Commande extends CommonOrder
$this->line->rang = $rangmax + 1; $this->line->rang = $rangmax + 1;
} }
$this->line->rowid=$rowid; $this->line->id=$rowid;
$this->line->label=$label; $this->line->label=$label;
$this->line->desc=$desc; $this->line->desc=$desc;
$this->line->qty=$qty; $this->line->qty=$qty;
@ -4267,11 +4267,11 @@ class OrderLine extends CommonOrderLine
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet'); $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet');
$this->rowid = $this->id;
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$this->id=$this->rowid;
$result=$this->insertExtraFields(); $result=$this->insertExtraFields();
if ($result < 0) if ($result < 0)
{ {

View File

@ -1175,7 +1175,7 @@ class Facture extends CommonInvoice
$this->availability_id = $object->availability_id; $this->availability_id = $object->availability_id;
$this->demand_reason_id = $object->demand_reason_id; $this->demand_reason_id = $object->demand_reason_id;
$this->date_livraison = $object->date_livraison; $this->date_livraison = $object->date_livraison;
$this->fk_delivery_address = $object->fk_delivery_address; $this->fk_delivery_address = $object->fk_delivery_address; // deprecated
$this->contact_id = $object->contactid; $this->contact_id = $object->contactid;
$this->ref_client = $object->ref_client; $this->ref_client = $object->ref_client;
@ -2016,7 +2016,7 @@ class Facture extends CommonInvoice
$list_rowid_det = array(); $list_rowid_det = array();
foreach ($this->lines as $key => $invoiceline) foreach ($this->lines as $key => $invoiceline)
{ {
$list_rowid_det[] = $invoiceline->rowid; $list_rowid_det[] = $invoiceline->id;
} }
// Consumned discounts are freed // Consumned discounts are freed
@ -3133,6 +3133,7 @@ class Facture extends CommonInvoice
$this->line->rang = $rangmax + 1; $this->line->rang = $rangmax + 1;
} }
$this->line->id = $rowid;
$this->line->rowid = $rowid; $this->line->rowid = $rowid;
$this->line->label = $label; $this->line->label = $label;
$this->line->desc = $desc; $this->line->desc = $desc;

View File

@ -1800,7 +1800,7 @@ class ExpenseReport extends CommonObject
if ($result > 0) if ($result > 0)
{ {
$this->db->commit(); $this->db->commit();
return $this->line->rowid; return $this->line->id;
} }
else else
{ {
@ -2049,7 +2049,6 @@ class ExpenseReport extends CommonObject
$this->line->fk_ecm_files = $fk_ecm_files; $this->line->fk_ecm_files = $fk_ecm_files;
$this->line->rowid = $rowid;
$this->line->id = $rowid; $this->line->id = $rowid;
// Select des infos sur le type fees // Select des infos sur le type fees
@ -2660,7 +2659,7 @@ class ExpenseReportLine
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'expensereport_det'); $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'expensereport_det');
if (! $fromaddline) if (! $fromaddline)
{ {

View File

@ -1031,7 +1031,7 @@ if ($action == 'create')
//var_dump($product->stock_warehouse[1]); //var_dump($product->stock_warehouse[1]);
print '<td>'; print '<td>';
print '<a name="'.$line->rowid.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne
// Show product and description // Show product and description
$product_static->type = $line->fk_product_type; $product_static->type = $line->fk_product_type;

View File

@ -4176,10 +4176,9 @@ class Societe extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux ';
$sql .= ' WHERE fk_soc = '.(int) $origin_id.') '; $sql .= ' WHERE fk_soc = '.(int) $origin_id.') ';
$query = $db->query($sql); $resql = $db->query($sql);
while ($obj = $db->fetch_object($resql)) {
while ($result = $db->fetch_object($query)) { $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.$obj->rowid);
$db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.$result->rowid);
} }
/** /**

View File

@ -399,7 +399,7 @@ if ($action == "order" and $placeid != 0)
$result = array_intersect($catsprinter1, $existing); $result = array_intersect($catsprinter1, $existing);
$count = count($result); $count = count($result);
if ($count > 0) { if ($count > 0) {
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=$line->rowid"; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=".$line->id;
$db->query($sql); $db->query($sql);
$order_receipt_printer1 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty; $order_receipt_printer1 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")"; if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer1 .= "<br>(".$line->array_options['options_order_notes'].")";
@ -416,7 +416,7 @@ if ($action == "order" and $placeid != 0)
$result = array_intersect($catsprinter2, $existing); $result = array_intersect($catsprinter2, $existing);
$count = count($result); $count = count($result);
if ($count > 0) { if ($count > 0) {
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=$line->rowid"; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where rowid=".$line->id;
$db->query($sql); $db->query($sql);
$order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty; $order_receipt_printer2 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer2 .= "<br>(".$line->array_options['options_order_notes'].")"; if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer2 .= "<br>(".$line->array_options['options_order_notes'].")";

View File

@ -662,6 +662,7 @@ class Ticket extends CommonObject
$line = new TicketsLine(); $line = new TicketsLine();
$line->id = $obj->rowid;
$line->rowid = $obj->rowid; $line->rowid = $obj->rowid;
$line->ref = $obj->ref; $line->ref = $obj->ref;
$line->track_id = $obj->track_id; $line->track_id = $obj->track_id;
@ -2783,7 +2784,13 @@ class Ticket extends CommonObject
*/ */
class TicketsLine class TicketsLine
{ {
/** /**
* @var int ID
* @deprecated
*/
public $rowid;
/**
* @var int ID * @var int ID
*/ */
public $id; public $id;

View File

@ -86,12 +86,12 @@ class ProductAttribute
return -1; return -1;
} }
$result = $this->db->fetch_object($query); $obj = $this->db->fetch_object($query);
$this->id = $result->rowid; $this->id = $obj->rowid;
$this->ref = $result->ref; $this->ref = $obj->ref;
$this->label = $result->label; $this->label = $obj->label;
$this->rang = $result->rang; $this->rang = $obj->rang;
return 1; return 1;
} }

View File

@ -85,12 +85,12 @@ class ProductAttributeValue
return -1; return -1;
} }
$result = $this->db->fetch_object($query); $obj = $this->db->fetch_object($query);
$this->id = $result->rowid; $this->id = $obj->rowid;
$this->fk_product_attribute = $result->fk_product_attribute; $this->fk_product_attribute = $obj->fk_product_attribute;
$this->ref = $result->ref; $this->ref = $obj->ref;
$this->value = $result->value; $this->value = $obj->value;
return 1; return 1;
} }

View File

@ -104,14 +104,14 @@ class ProductCombination
return -1; return -1;
} }
$result = $this->db->fetch_object($query); $obj = $this->db->fetch_object($query);
$this->id = $result->rowid; $this->id = $obj->rowid;
$this->fk_product_parent = $result->fk_product_parent; $this->fk_product_parent = $obj->fk_product_parent;
$this->fk_product_child = $result->fk_product_child; $this->fk_product_child = $obj->fk_product_child;
$this->variation_price = $result->variation_price; $this->variation_price = $obj->variation_price;
$this->variation_price_percentage = $result->variation_price_percentage; $this->variation_price_percentage = $obj->variation_price_percentage;
$this->variation_weight = $result->variation_weight; $this->variation_weight = $obj->variation_weight;
return 1; return 1;
} }

View File

@ -128,12 +128,12 @@ class ProductCombination2ValuePair
$return = array(); $return = array();
while ($result = $this->db->fetch_object($query)) { while ($obj = $this->db->fetch_object($query)) {
$tmp = new ProductCombination2ValuePair($this->db); $tmp = new ProductCombination2ValuePair($this->db);
$tmp->fk_prod_attr_val = $result->fk_prod_attr_val; $tmp->fk_prod_attr_val = $obj->fk_prod_attr_val;
$tmp->fk_prod_attr = $result->fk_prod_attr; $tmp->fk_prod_attr = $obj->fk_prod_attr;
$tmp->fk_prod_combination = $result->fk_prod_combination; $tmp->fk_prod_combination = $obj->fk_prod_combination;
$tmp->id = $result->rowid; $tmp->id = $obj->rowid;
$return[] = $tmp; $return[] = $tmp;
} }

View File

@ -322,7 +322,7 @@ function getInvoice($authentication, $id = '', $ref = '', $ref_ext = '')
{ {
//var_dump($line); exit; //var_dump($line); exit;
$linesresp[]=array( $linesresp[]=array(
'id'=>$line->rowid, 'id'=>$line->id,
'type'=>$line->product_type, 'type'=>$line->product_type,
'desc'=>dol_htmlcleanlastbr($line->desc), 'desc'=>dol_htmlcleanlastbr($line->desc),
'total_net'=>$line->total_ht, 'total_net'=>$line->total_ht,
@ -458,17 +458,17 @@ function getInvoicesForThirdParty($authentication, $idthirdparty)
foreach($invoice->lines as $line) foreach($invoice->lines as $line)
{ {
$linesresp[]=array( $linesresp[]=array(
'id'=>$line->rowid, 'id'=>$line->id,
'type'=>$line->product_type, 'type'=>$line->product_type,
'total_net'=>$line->total_ht, 'total_net'=>$line->total_ht,
'total_vat'=>$line->total_tva, 'total_vat'=>$line->total_tva,
'total'=>$line->total_ttc, 'total'=>$line->total_ttc,
'vat_rate'=>$line->tva_tx, 'vat_rate'=>$line->tva_tx,
'qty'=>$line->qty, 'qty'=>$line->qty,
'unitprice'=> $line->subprice, 'unitprice'=> $line->subprice,
'date_start'=> $line->date_start?dol_print_date($line->date_start, 'dayrfc'):'', 'date_start'=> $line->date_start?dol_print_date($line->date_start, 'dayrfc'):'',
'date_end'=> $line->date_end?dol_print_date($line->date_end, 'dayrfc'):'', 'date_end'=> $line->date_end?dol_print_date($line->date_end, 'dayrfc'):'',
'product_id'=>$line->fk_product, 'product_id'=>$line->fk_product,
'product_ref'=>$line->product_ref, 'product_ref'=>$line->product_ref,
'product_label'=>$line->product_label, 'product_label'=>$line->product_label,
'product_desc'=>$line->product_desc, 'product_desc'=>$line->product_desc,