NEW Add Next/Previous button on operation date of bank line
Operation date has to be frequently updated because some bank change them in many case. With this feature, this value can be updated simply like the value date.
This commit is contained in:
parent
ded6b40489
commit
b6b3ab3f1b
@ -1127,7 +1127,16 @@ if ($resql)
|
||||
// Date ope
|
||||
if (! empty($arrayfields['b.dateo']['checked']))
|
||||
{
|
||||
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->do),"day")."</td>\n";
|
||||
print '<td align="center" class="nowrap">';
|
||||
print '<span id="dateoperation_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->do),"day")."</span>";
|
||||
print ' ';
|
||||
print '<span class="inline-block">';
|
||||
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=doprev&account='.$objp->bankid.'&rowid='.$objp->rowid.'">';
|
||||
print img_edit_remove() . "</a> ";
|
||||
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=donext&account='.$objp->bankid.'&rowid='.$objp->rowid.'">';
|
||||
print img_edit_add() ."</a>";
|
||||
print '</span>';
|
||||
print "</td>\n";
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
|
||||
@ -1959,6 +1959,67 @@ class AccountLine extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increase/decrease operation date of a rowid
|
||||
*
|
||||
* @param int $rowid Id of line
|
||||
* @param int $sign 1 or -1
|
||||
* @return int >0 if OK, 0 if KO
|
||||
*/
|
||||
function dateo_change($rowid,$sign=1)
|
||||
{
|
||||
$sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->db->fetch_object($resql);
|
||||
$newdate=$this->db->jdate($obj->dateo)+(3600*24*$sign);
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bank SET";
|
||||
$sql.= " dateo = '".$this->db->idate($newdate)."'";
|
||||
$sql.= " WHERE rowid = ".$rowid;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->affected_rows($result))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else dol_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase operation date of a rowid
|
||||
*
|
||||
* @param int $id Id of line to change
|
||||
* @return int >0 if OK, 0 if KO
|
||||
*/
|
||||
function dateo_next($id)
|
||||
{
|
||||
return $this->dateo_change($id,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease operation date of a rowid
|
||||
*
|
||||
* @param int $id Id of line to change
|
||||
* @return int >0 if OK, 0 if KO
|
||||
*/
|
||||
function dateo_previous($id)
|
||||
{
|
||||
return $this->dateo_change($id,-1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load miscellaneous information for tab "Info"
|
||||
*
|
||||
|
||||
@ -71,13 +71,20 @@ if ($cancel)
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->rights->banque->consolidate && $action == 'dvnext')
|
||||
|
||||
if ($user->rights->banque->consolidate && $action == 'donext')
|
||||
{
|
||||
$al = new AccountLine($db);
|
||||
$al->dateo_next($_GET["rowid"]);
|
||||
}elseif ($user->rights->banque->consolidate && $action == 'doprev')
|
||||
{
|
||||
$al = new AccountLine($db);
|
||||
$al->dateo_previous($_GET["rowid"]);
|
||||
}elseif ($user->rights->banque->consolidate && $action == 'dvnext')
|
||||
{
|
||||
$al = new AccountLine($db);
|
||||
$al->datev_next($_GET["rowid"]);
|
||||
}
|
||||
|
||||
if ($user->rights->banque->consolidate && $action == 'dvprev')
|
||||
}elseif ($user->rights->banque->consolidate && $action == 'dvprev')
|
||||
{
|
||||
$al = new AccountLine($db);
|
||||
$al->datev_previous($_GET["rowid"]);
|
||||
@ -479,6 +486,14 @@ if ($result)
|
||||
{
|
||||
print '<td>';
|
||||
print $form->select_date($db->jdate($objp->do),'dateo','','','','update',1,0,1,$objp->rappro);
|
||||
if (! $objp->rappro)
|
||||
{
|
||||
print ' ';
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=doprev&id='.$id.'&rowid='.$objp->rowid.'">';
|
||||
print img_edit_remove() . "</a> ";
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=donext&id='.$id.'&rowid='.$objp->rowid.'">';
|
||||
print img_edit_add() ."</a>";
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
|
||||
@ -71,3 +71,27 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $
|
||||
exit;
|
||||
}
|
||||
|
||||
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext')
|
||||
{
|
||||
// Increase date
|
||||
$al = new AccountLine($db);
|
||||
$al->dateo_next(GETPOST('rowid','int'));
|
||||
$al->fetch(GETPOST('rowid','int'));
|
||||
|
||||
print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>';
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev')
|
||||
{
|
||||
// Decrease date
|
||||
$al =new AccountLine($db);
|
||||
$al->dateo_previous(GETPOST('rowid','int'));
|
||||
$al->fetch(GETPOST('rowid','int'));
|
||||
|
||||
print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>';
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user