task #1122 : Change Annulation in the comment by Extourne

Add a tab "Extourne in the confirmation of Sale, Purchase and Misc Operation
This commit is contained in:
Dany De Bontridder 2015-06-03 23:14:20 +02:00
parent d181934cb2
commit 49d75c2ad6
5 changed files with 151 additions and 19 deletions

View file

@ -220,7 +220,7 @@ class Acc_Ledger extends jrn_def_sql
// Mark the operation invalid into the ledger
// to avoid to nullify twice the same op.
$sql = "update jrn set jr_comment='Annule : '||jr_comment where jr_id=$1";
$sql = "update jrn set jr_comment='extourne : '||jr_comment where jr_id=$1";
$Res = $this->db->exec_sql($sql, array($this->jr_id));
// Check return code
@ -287,7 +287,7 @@ class Acc_Ledger extends jrn_def_sql
jr_internal
,jr_tech_per, jr_valid
)
select $1,jr_def_id,jr_montant,'Annulation '||jr_comment,
select $1,jr_def_id,jr_montant,jr_comment,
to_date($2,'DD.MM.YYYY'),$3,$4,
$5, true
from
@ -326,6 +326,7 @@ class Acc_Ledger extends jrn_def_sql
$Res = $this->db->exec_sql($sql);
if ($Res == false)
throw (new Exception(__FILE__ . __LINE__ . "SQL ERROR [ $sql ]"));
$this->db->commit();
}
catch (Exception $e)
{
@ -1518,7 +1519,9 @@ class Acc_Ledger extends jrn_def_sql
if (trim(${'qc_' . $i}) == "" && trim(${'poste' . $i}) == "")
continue;
$ret.="<td>" . h(${"ld" . $i}) . HtmlInput::hidden('ld' . $i, ${'ld' . $i}) . "</td>";
$ret.="<td>" . h(${"ld" . $i}) . HtmlInput::hidden('ld' . $i, ${'ld' . $i}) ;
$ret .=(isset(${"ck$i"})) ? HtmlInput::hidden('ck' . $i, ${'ck' . $i}) : "";
$ret .= "</td>";
if (isset(${"ck$i"}))
{
$ret.="<td class=\"num\">" . nbm(${"amount" . $i}) . HtmlInput::hidden('amount' . $i, ${'amount' . $i}) . "</td>" . td("");
@ -1529,9 +1532,9 @@ class Acc_Ledger extends jrn_def_sql
$ret.=td("") . "<td class=\"num\">" . nbm(${"amount" . $i}) . HtmlInput::hidden('amount' . $i, ${'amount' . $i}) . "</td>";
$total_cred = bcadd($total_cred, ${"amount" . $i});
}
$ret.="<td>";
/*$ret.="<td>";
$ret.=(isset(${"ck$i"})) ? HtmlInput::hidden('ck' . $i, ${'ck' . $i}) : "";
$ret.="</td>";
$ret.="</td>";*/
// CA
if ($g_parameter->MY_ANALYTIC != 'nu') // use of AA
@ -3903,7 +3906,7 @@ class Acc_Ledger extends jrn_def_sql
public function select_depot($p_readonly, $p_repo)
{
global $g_parameter;
$r='<div id="repo_div_id" style="height:185px;height:10rem;">';
$r=($p_readonly==false)?'<div id="repo_div_id" style="height:185px;height:10rem;">':'<div id="repo_div_id" >';
// Show the available repository
if ($g_parameter->MY_STOCK=='Y')
{

View file

@ -78,10 +78,14 @@ if (isset($_POST['view_invoice']))
echo HtmlInput::hidden('ac', $_REQUEST['ac']);
?>
<div id="tab_id" >
<script>
var a_tab = ['modele_div_id','repo_div_id','facturation_div_id','reverse_div_id'];
</script>
<ul class="tabs">
<li class="tabs_selected"><a href="javascript:void(0)" title="<?php echo _("Générer une facture ou charger un document")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';$('modele_div_id').hide();$('repo_div_id').hide();$('facturation_div_id').show();"><?php echo _('Facture')?></a></li>
<li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Choix du dépôt")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';$('modele_div_id').hide();$('facturation_div_id').hide();$('repo_div_id').show();"> <?php echo _('Dépôt')?> </a></li>
<li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Modèle à sauver")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';$('facturation_div_id').hide();$('repo_div_id').hide();$('modele_div_id').show()"> <?php echo _('Modèle')?> </a></li>
<li class="tabs_selected"><a href="javascript:void(0)" title="<?php echo _("Générer une facture ou charger un document")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'facturation_div_id')"><?php echo _('Facture')?></a></li>
<li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Choix du dépôt")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'repo_div_id')"> <?php echo _('Dépôt')?> </a></li>
<li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Modèle à sauver")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'modele_div_id')"> <?php echo _('Modèle')?> </a></li>
<li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Extourne")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'reverse_div_id')"> <?php echo _('Extourne')?> </a></li>
</ul>
<?php
echo $Ledger->select_depot(false, -1);
@ -91,15 +95,24 @@ if (isset($_POST['view_invoice']))
echo Pre_operation::save_propose();
echo '</div>';
echo HtmlInput::submit("record", _("Enregistrement"), 'onClick="return verify_ca(\'\');"');
echo '<div id="reverse_div_id" style="display:none;height:185px;height:10rem">';
$reverse_date=new IDate('reverse_date');
$reverse_ck=new ICheckBox('reverse_ck');
echo _('Extourne opération')." ".$reverse_ck->input()." ";
echo $reverse_date->input();
echo '</div>';
echo HtmlInput::submit("record", _("Enregistrement"), 'onClick="return verify_ca(\'\');"');
echo HtmlInput::submit('correct', _("Corriger"));
echo '</form>';
echo '</div>'; /* tab_id */
echo '</div>';
?>
<script>
$('repo_div_id').hide();
$('repo_div_id').hide();
$('modele_div_id').hide();
show_tab(a_tab,'facturation_div_id');
</script>
<?php
echo '</div>';
@ -157,6 +170,33 @@ if (isset($_POST['record']))
echo '<h2>'._('Document').'</h2>';
echo $Ledger->doc;
}
// extourne
if (isset($_POST['reverse_ck']))
{
$p_date=HtmlInput::default_value_post('reverse_date', '');
if (isDate($p_date)==$p_date)
{
// reverse the operation
try
{
$Ledger->reverse($p_date);
echo '<p>';
echo _('Extourné au ').$p_date;
echo '</p>';
}
catch (Exception $e)
{
echo '<p class="notice">'._('Opération non extournée').
$e->getMessage().
'</p>';
}
}
else
{
// warning because date is invalid
echo '<p class="notice">'._('Date invalide, opération non extournée').'</p>';
}
}
echo $Ledger->button_new_operation();
echo '</div>';
return;

View file

@ -100,6 +100,34 @@ elseif (isset($_POST['save']))
// show feedback
echo '<div id="jrn_name_div">'; echo '<h2 id="jrn_name" style="display:inline">' . $ledger->get_name() . '</h2>'; echo '</div>';
echo $ledger->confirm($_POST, true);
// extourne
if (isset($_POST['reverse_ck']))
{
$p_date=HtmlInput::default_value_post('reverse_date', '');
if (isDate($p_date)==$p_date)
{
// reverse the operation
try
{
$ledger->reverse($p_date);
echo '<p>';
echo _('Extourné au ').$p_date;
echo '</p>';
}
catch (Exception $e)
{
echo '<p class="notice">'._('Opération non extournée').
$e->getMessage().
'</p>';
}
}
else
{
// warning because date is invalid
echo '<p class="notice">'._('Date invalide, opération non extournée').'</p>';
}
}
echo $ledger->button_new_operation();
}

View file

@ -87,10 +87,14 @@ $p_msg="";
echo HtmlInput::hidden('ac',$_REQUEST['ac']);
?>
<div id="tab_id" >
<script>
var a_tab = ['modele_div_id','repo_div_id','facturation_div_id','reverse_div_id'];
</script>
<ul class="tabs">
<li class="tabs_selected"><a href="javascript:void(0)" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';$('modele_div_id').hide();$('repo_div_id').hide();$('facturation_div_id').show();"><?php echo _('Facture')?></a></li>
<li class="tabs"> <a href="javascript:void(0)" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';$('modele_div_id').hide();$('facturation_div_id').hide();$('repo_div_id').show();"> <?php echo _('Dépôt')?> </a></li>
<li class="tabs"> <a href="javascript:void(0)" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';$('facturation_div_id').hide();$('repo_div_id').hide();$('modele_div_id').show()"> <?php echo _('Modèle')?> </a></li>
<li class="tabs_selected"><a href="javascript:void(0)" title="<?php echo _("Générer une facture ou charger un document")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'facturation_div_id')"><?php echo _('Facture')?></a></li>
<li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Choix du dépôt")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'repo_div_id')"> <?php echo _('Dépôt')?> </a></li>
<li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Modèle à sauver")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'modele_div_id')"> <?php echo _('Modèle')?> </a></li>
<li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Extourne")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'reverse_div_id')"> <?php echo _('Extourne')?> </a></li>
</ul>
<?php
echo $Ledger->select_depot(false, -1);
@ -99,6 +103,14 @@ $p_msg="";
echo Pre_operation::save_propose();
echo '</div>';
echo '<div id="reverse_div_id" style="display:none;height:185px;height:10rem">';
$reverse_date=new IDate('reverse_date');
$reverse_ck=new ICheckBox('reverse_ck');
echo _('Extourne opération')." ".$reverse_ck->input()." ";
echo $reverse_date->input();
echo '</div>';
echo HtmlInput::hidden('ac',$_REQUEST['ac']);
echo HtmlInput::submit("record",_("Enregistrement"),'onClick="return verify_ca(\'\');"');
echo HtmlInput::submit('correct',_("Corriger"));
@ -107,8 +119,9 @@ $p_msg="";
echo '</div>'; /* tab_id */
?>
<script>
$('repo_div_id').hide();
$('repo_div_id').hide();
$('modele_div_id').hide();
show_tab(a_tab,'facturation_div_id');
</script>
<?php
echo '</div>';
@ -173,6 +186,34 @@ $p_msg="";
/* Save the additional information into jrn_info */
$obj=new Acc_Ledger_Info($cn);
$obj->save_extra($Ledger->jr_id,$_POST);
// extourne
if (isset($_POST['reverse_ck']))
{
$p_date=HtmlInput::default_value_post('reverse_date', '');
if (isDate($p_date)==$p_date)
{
// reverse the operation
try
{
$Ledger->reverse($p_date);
echo '<p>';
echo _('Extourné au ').$p_date;
echo '</p>';
}
catch (Exception $e)
{
echo '<p class="notice">'._('Opération non extournée').
$e->getMessage().
'</p>';
}
}
else
{
// warning because date is invalid
echo '<p class="notice">'._('Date invalide, opération non extournée').'</p>';
}
}
echo $Ledger->button_new_operation();

View file

@ -41,11 +41,31 @@ echo '<FORM METHOD="POST" class="print">';
echo HtmlInput::request_to_hidden(array('ac'));
echo $ledger->confirm($_POST,false);
echo '<hr>';
echo Pre_operation::save_propose();
echo '<hr>';
?>
<div id="tab_id" >
<script>
var a_tab = ['modele_div_id','reverse_div_id'];
</script>
<ul class="tabs">
<li class="tabs_selected"> <a href="javascript:void(0)" title="<?php echo _("Modèle à sauver")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'modele_div_id')"> <?php echo _('Modèle')?> </a></li>
<li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Extourne")?>" onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';show_tabs(a_tab,'reverse_div_id')"> <?php echo _('Extourne')?> </a></li>
</ul>
<div id="modele_div_id">
<?php echo Pre_operation::save_propose(); ?>
</div>
<div id="reverse_div_id" style="display:none;height:185px;height:10rem">
<?php
$reverse_date=new IDate('reverse_date');
$reverse_ck=new ICheckBox('reverse_ck');
echo _('Extourne opération')." ".$reverse_ck->input()." ";
echo $reverse_date->input();
?>
</div>
</div>
<?php
echo HtmlInput::submit("save","Confirmer");
echo HtmlInput::submit("correct","Corriger");
echo '</FORM>';
?>
</FORM>