mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into NEW_deposit_payment_terms
This commit is contained in:
@@ -2942,15 +2942,20 @@ abstract class CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position'
|
||||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
// Count number of lines to reorder (according to choice $renum)
|
||||
$nl = 0;
|
||||
$sql = "SELECT count(rowid) FROM ".$this->db->prefix().$this->table_element_line;
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
if (!$renum) {
|
||||
$sql .= ' AND rang = 0';
|
||||
$sql .= " AND " . $fieldposition . " = 0";
|
||||
}
|
||||
if ($renum) {
|
||||
$sql .= ' AND rang <> 0';
|
||||
$sql .= " AND " . $fieldposition . " <> 0";
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::line_order", LOG_DEBUG);
|
||||
@@ -2971,7 +2976,7 @@ abstract class CommonObject
|
||||
if ($fk_parent_line) {
|
||||
$sql .= ' AND fk_parent_line IS NULL';
|
||||
}
|
||||
$sql .= " ORDER BY rang ASC, rowid ".$rowidorder;
|
||||
$sql .= " ORDER BY " . $fieldposition . " ASC, rowid " . $rowidorder;
|
||||
|
||||
dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -3012,12 +3017,17 @@ abstract class CommonObject
|
||||
*/
|
||||
public function getChildrenOfLine($id, $includealltree = 0)
|
||||
{
|
||||
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position'
|
||||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
|
||||
$sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= ' AND fk_parent_line = '.((int) $id);
|
||||
$sql .= ' ORDER BY rang ASC';
|
||||
$sql .= " ORDER BY " . $fieldposition . " ASC";
|
||||
|
||||
dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -3088,7 +3098,7 @@ abstract class CommonObject
|
||||
{
|
||||
global $hookmanager;
|
||||
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position'
|
||||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) {
|
||||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
@@ -3134,13 +3144,13 @@ abstract class CommonObject
|
||||
{
|
||||
if ($rang > 1) {
|
||||
$fieldposition = 'rang';
|
||||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) {
|
||||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= ' AND rang = '.((int) ($rang - 1));
|
||||
$sql .= " AND " . $fieldposition . " = " . ((int) ($rang - 1));
|
||||
if ($this->db->query($sql)) {
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1));
|
||||
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||
@@ -3165,13 +3175,13 @@ abstract class CommonObject
|
||||
{
|
||||
if ($rang < $max) {
|
||||
$fieldposition = 'rang';
|
||||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) {
|
||||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= ' AND rang = '.((int) ($rang + 1));
|
||||
$sql .= " AND " . $fieldposition . " = " . ((int) ($rang + 1));
|
||||
if ($this->db->query($sql)) {
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1));
|
||||
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||
@@ -3192,7 +3202,12 @@ abstract class CommonObject
|
||||
*/
|
||||
public function getRangOfLine($rowid)
|
||||
{
|
||||
$sql = "SELECT rang FROM ".$this->db->prefix().$this->table_element_line;
|
||||
$fieldposition = 'rang';
|
||||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
$sql = "SELECT " . $fieldposition . " FROM ".$this->db->prefix().$this->table_element_line;
|
||||
$sql .= " WHERE rowid = ".((int) $rowid);
|
||||
|
||||
dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG);
|
||||
@@ -3211,9 +3226,14 @@ abstract class CommonObject
|
||||
*/
|
||||
public function getIdOfLine($rang)
|
||||
{
|
||||
$fieldposition = 'rang';
|
||||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||
$fieldposition = 'position';
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= " AND rang = ".((int) $rang);
|
||||
$sql .= " AND " . $fieldposition . " = ".((int) $rang);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$row = $this->db->fetch_row($resql);
|
||||
@@ -3232,7 +3252,7 @@ abstract class CommonObject
|
||||
{
|
||||
// phpcs:enable
|
||||
$positionfield = 'rang';
|
||||
if ($this->table_element == 'bom_bom') {
|
||||
if (in_array($this->table_element, array('bom_bom', 'product_attribute'))) {
|
||||
$positionfield = 'position';
|
||||
}
|
||||
|
||||
@@ -6659,7 +6679,7 @@ abstract class CommonObject
|
||||
|
||||
// Add validation state class
|
||||
if (!empty($validationClass)) {
|
||||
$morecss.= ' '.$validationClass;
|
||||
$morecss.= $validationClass;
|
||||
}
|
||||
|
||||
if (in_array($type, array('date'))) {
|
||||
@@ -7078,6 +7098,8 @@ abstract class CommonObject
|
||||
$paramforthenewlink = '';
|
||||
$paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : '');
|
||||
$paramforthenewlink .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : '');
|
||||
$paramforthenewlink .= (GETPOSTISSET('origin') ? '&origin='.GETPOST('origin', 'aZ09') : '');
|
||||
$paramforthenewlink .= (GETPOSTISSET('originid') ? '&originid='.GETPOST('originid', 'int') : '');
|
||||
$paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--';
|
||||
// TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page
|
||||
$out .= '<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
|
||||
|
||||
Reference in New Issue
Block a user